Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Interpret $? variable

by rbala (Acolyte)
on Sep 12, 2013 at 09:40 UTC ( #1053686=perlquestion: print w/ replies, xml ) Need Help??
rbala has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, When a process is successful I see the value stored in this variable is 0. But , if unsucessful, the value is undeterministic and for various commands, I get different outputs. But I just need to check if the command is successful or not. My doubt is, can i confirm that if $? is 0 , then the command is successful ? Thanks, Bala.

Comment on Interpret $? variable
Re: Interpret $? variable
by daxim (Chaplain) on Sep 12, 2013 at 09:50 UTC
    Yes, that's the convention. I recommend IPC::System::Simple which has a very convenient API for this use-case.

    use IPC::System::Simple qw(runx); runx [0], 'some_command', @more_arguments;
Re: Interpret $? variable
by mtmcc (Hermit) on Sep 12, 2013 at 09:51 UTC
    It depends on the command.

    Have a look at this. I hope it's helpful.

      Thank you
Re: Interpret $? variable
by Marshall (Prior) on Sep 13, 2013 at 06:36 UTC
    Yes,
    The return value of "zero" usually means success.

    Something other than "0" usually means "Oops -
    problem with an error code".

    The error code is deterministic, but depends upon
    the error codes for that subroutine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1053686]
Approved by Corion
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-07-30 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls