Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Interpret $? variable

by rbala (Acolyte)
on Sep 12, 2013 at 09:40 UTC ( [id://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 (Curate) 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 (Canon) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found