Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: need both from system-call

by physi (Friar)
on Apr 27, 2001 at 11:27 UTC ( [id://76038]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to need both from system-call

Upps I discovered $?. But there is a strange behavior in the following codes:
xx.pl:
#!/usr/bin/perl print"STATUS:$?\n"; $result=`./xxx.pl`; $status=$?; print "RES:$result\nSTA:$status\n";
xxx.pl:
#!/usr/bin/perl print"Wonderful world on Friday\n"; exit 200;
This results in:
STATUS:0 RES:Wonderful world on Friday STA:25600
Why ???
Is 255 the return code from the second #!/usr/bin/perl ?
I'm a little bit confused ...
----------------------------------- --the good, the bad and the physi-- -----------------------------------

Replies are listed 'Best First'.
Re: Re: need both from system-call
by hdp (Beadle) on Apr 27, 2001 at 12:20 UTC
    As perlvar documents, $? is "just the 16-bit status word returned by the wait() system call (or else is made up to look like it). Thus, the exit value of the subprocess is really ('$? >> 8')". It looks like perl thinks the exit value it got was 100.

    hdp.

Re: Re: need both from system-call
by birdbrane (Chaplain) on Apr 27, 2001 at 12:20 UTC
    Look under "exit status" of the camel book. $? is the entire 16 bit status code. You only want the last 8 bits.

    This will fix your code: $status = $? >> 8; bb

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76038]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.