Help in system function

Help in system function

am 17.01.2008 15:16:17 von Irfan.Sayed

------_=_NextPart_001_01C85913.89444F5C
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All,

=20

I am executing following command in Perl script

=20

$vw=3Dsystem("mk_view $view_name ETC");

if ($vw)

{ print "view created successfully\n";

}

=20

When I run this command, I am getting message "view created
successfully". But in reality command is not executing at all

=20

Please help

=20

Regards

Irfan.

=20


------_=_NextPart_001_01C85913.89444F5C--

RE: Help in system function

am 17.01.2008 15:40:13 von Irfan.Sayed

------_=_NextPart_001_01C85916.E10FFB7C
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,

=20

Here is the modified code

=20

$vw=3Dsystem("mk_view $view_name ETC");

print "$vw\n";

if ($vw)

{ print "view is not created\n";

}

else{

print "View is created \n";

=20

Please help

=20

Regards

Irfan.

=20

=20

________________________________

From: Sayed, Irfan=20
Sent: Thursday, January 17, 2008 7:46 PM
To: 'beginners@perl.org'
Subject: Help in system function

=20

Hi All,

=20

I am executing following command in Perl script

=20

$vw=3Dsystem("mk_view $view_name ETC");

if ($vw)

{ print "view created successfully\n";

}

=20

When I run this command, I am getting message "view created
successfully". But in reality command is not executing at all

=20

Please help

=20

Regards

Irfan.

=20


------_=_NextPart_001_01C85916.E10FFB7C--

Re: Help in system function

am 17.01.2008 15:50:19 von Stephen Kratzer

On Thursday 17 January 2008 09:16:17 Irfan.Sayed@t-systems.com wrote:
> Hi All,
>
>
>
> I am executing following command in Perl script
>
>
>
> $vw=system("mk_view $view_name ETC");
>
> if ($vw)
>
> { print "view created successfully\n";
>
> }
>
>
>
> When I run this command, I am getting message "view created
> successfully". But in reality command is not executing at all
>
>
>
> Please help
>
>
>
> Regards
>
> Irfan.

For most commands on most UNIX-like systems, a non-zero return value indicates
failure and not success. Try using 'unless' instead of 'if'.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Help in system function

am 17.01.2008 16:06:27 von ROB.DIXON

Irfan.Sayed@t-systems.com wrote:
> Hi,
>
> Here is the modified code
>
> $vw=system("mk_view $view_name ETC");
>
> print "$vw\n";
>
> if ($vw)
>
> { print "view is not created\n";
>
> }
>
> else{
>
> print "View is created \n";
>
>
> Please help

And what is the modified problem?

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

´ð¸´: Help in system function

am 17.01.2008 16:09:25 von Chen Yue

If you are in a *nix system, you can try to run=20

$result=3D` mk_view $view_name ETC` =20

instead and see the output from $result. It may be helpful to find the =
root
cause.

-----ÓʼþÔ­¼þ-----
·¢¼þÈË: Irfan.Sayed@t-systems.com =
[mailto:Irfan.Sayed@t-systems.com]=20
·¢ËÍʱ¼ä: 2008Äê1ÔÂ17ÈÕ 22:16
ÊÕ¼þÈË: beginners@perl.org
Ö÷Ìâ: Help in system function

Hi All,

=20

I am executing following command in Perl script

=20

$vw=3Dsystem("mk_view $view_name ETC");

if ($vw)

{ print "view created successfully\n";

}

=20

When I run this command, I am getting message "view created
successfully". But in reality command is not executing at all

=20

Please help

=20

Regards

Irfan.

=20



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: ´ð¸´: Help in system function

am 17.01.2008 18:44:37 von Paul Lalli

On Jan 17, 10:09 am, godsarm...@gmail.com (Chen Yue) wrote:
> If you are in a *nix system, you can try to run
>
> $result=` mk_view $view_name ETC`
>
> instead and see the output from $result. It may be helpful to find the root
> cause.

You've got it backwards.

system("...")
caues the output to be printed to the screen.

`...`
causes the output to be returned.

In either case, the OP said the command is not being executed, which
means it's not generating any output.

Paul Lalli


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

RE: Help in system function

am 18.01.2008 16:00:10 von Irfan.Sayed

Hello Rob,

I just want to find out whether command("mk_view $view_name ETC") is
properly running or not. In order to acieve this I have written this
code.

Please suggest what needs to be done to get the proper output.

Please help

Regards
Irfan.
=20

-----Original Message-----
From: Rob Dixon [mailto:rob.dixon@350.com]=20
Sent: Thursday, January 17, 2008 8:36 PM
To: beginners@perl.org
Subject: Re: Help in system function

Irfan.Sayed@t-systems.com wrote:
> Hi,
>=20
> Here is the modified code
>=20
> $vw=3Dsystem("mk_view $view_name ETC");
>=20
> print "$vw\n";
>=20
> if ($vw)
>=20
> { print "view is not created\n";
>=20
> }
>=20
> else{
>=20
> print "View is created \n";
> =20
>=20
> Please help

And what is the modified problem?

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional
commands, e-mail: beginners-help@perl.org http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Help in system function

am 18.01.2008 17:56:01 von Tom Phoenix

On Jan 18, 2008 7:00 AM, wrote:

> I just want to find out whether command("mk_view $view_name ETC") is
> properly running or not.

I think you're looking for the program's exit status. Traditionally on
Unix and many similar systems, the exit status is an integer, with 0
meaning "normal exit" and anything else meaning that something went
wrong. That's the value that's used by programs that run other
programs (such as the 'make' system utility) and need to know when a
step has failed. In Perl, you can access the exit status with the $?
variable after running a command via system or backticks. Beware: If
your command is run by the shell, you'll get the shell's exit status,
which may not be the exit status you were looking for.

system $command;
if ($?) {
print "Oops, the command failed.\n"
}

If the program you're running itself doesn't notice that things have
failed, of course, it won't be able to tell your program. In that
case, you'll want to fix the external program, or find another way to
identify problems.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Help in system function

am 18.01.2008 20:09:32 von Harry Putnam

"Tom Phoenix" writes:

> On Jan 18, 2008 7:00 AM, wrote:
>
>> I just want to find out whether command("mk_view $view_name ETC") is
>> properly running or not.
>
> I think you're looking for the program's exit status. Traditionally on
> Unix and many similar systems, the exit status is an integer, with 0
> meaning "normal exit" and anything else meaning that something went
> wrong. That's the value that's used by programs that run other
> programs (such as the 'make' system utility) and need to know when a
> step has failed. In Perl, you can access the exit status with the $?
> variable after running a command via system or backticks. Beware: If
> your command is run by the shell, you'll get the shell's exit status,
> which may not be the exit status you were looking for.
>
> system $command;
> if ($?) {
> print "Oops, the command failed.\n"

Sorry to butt in here with a novice question but this issue is
something I've recently been trying to use in some scripting.

I thought this might be one way to get at the exit status of system,
maybe its not such a good way?

if((system( "$somecmd $cmdflgs"))== 0){
print "Yippie <$somecmd $cmdflgs> completed successfully\n";
}



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/