Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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.

Replies are listed 'Best First'.
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 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 Marshall (Abbot) on Sep 13, 2013 at 06:36 UTC
    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1053686]
Approved by Corion
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-05-23 06:24 GMT
Find Nodes?
    Voting Booth?