rovf has asked for the wisdom of the Perl Monks concerning the following question:
This is basically how I use IPC::Run::run and check for success and exit code:
This piece of code is supposed to run under Unix and Windows. You will notice that I'm throwing away the low byte of $?. My understanding is that this would be not equal to zero only if the command could not be run, in which case run throws an exception anyway. On the cases I found so far, this seemed to be true: I never had a $? with low byte not zero. Can I rely on this, or do I have to evaluate $? & 0xff as well? Is there anything else I'm missing?... eval { IPC::Run::run \@cmd, '>>', $outfile, '2>&1'; }; if($@) { # Could not run the program $fail_to_run=$@; $exitcode=undef; } else { $fail_to_run=undef; $exitcode=$? >> 8; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting exit code after IPC::Run (Windows vs. Unix)
by jettero (Monsignor) on Aug 12, 2009 at 12:32 UTC | |
by rovf (Priest) on Aug 12, 2009 at 13:16 UTC | |
|
Re: Getting exit code after IPC::Run (Windows vs. Unix)
by cdarke (Prior) on Aug 12, 2009 at 13:02 UTC |