On 5/1/07, Vladimir Lemberg <[EMAIL PROTECTED]> wrote:

My script is executing external program, which returns code i.e 0, -1, -2, -3 
etc

if ($? == -3) {

This is not working. Nothing is printing to the log file when I'm simulating
-3 code. If I print $?, it shown 65280.

The value in $? is derived from the exit code, but it includes more
information when a program fails. The full story is in the perlvar
manpage, but you can recover the exit code something like this:

   my $exit_code = $? >> 8;
   $exit_code -= 256 if $exit_code > 127;  # fix sign

The value 65280 shows an exit code of -1 by this method.

One other detail can be very important: If your command invokes a
shell to run another program, the exit code will be that of the shell,
instead of the other program. To get the external program's exit code,
Perl has to run the exernal program directly.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to