in reply to Problem in System function

It has been over a year since i last delt with system call return values, but if my memory server me correct, you need to right shift the status return. When i last coded this, i wrote a forking server that retrieved exit codes via the $? variable:

my $status = $? >> 8;
Using a little one liner, we can quickly see what 256 >> 8 is:
perl -le'print 256 >> 8'
Which yields 1 -- looks to me as if your invoked program is indeed returning a non zero return code. Are you also capturing STDERR?

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: Problem in System function
by rakesh1377 (Novice) on May 25, 2004 at 13:46 UTC
    perl -le'print 256 >> 8' returns 1 so 1 is failure or success?

      You can only say one thing about a return code of 1 ... it is not 0.

      Zero is conventionally "success" ... it means "there was no error to be reported" ... hence, zero.

      Everything else is treated as Not 0 ... it could mean failure, it could mean a warning, it could mean success. It is up to the person(s) who wrote the code you are running. This is why i think it is vital to capture STDERR as well.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)