Operating System - Linux
1752588 Members
4298 Online
108788 Solutions
New Discussion юеВ

Re: difference between $? in shell and perl programming

 
Karthik_sg
Frequent Advisor

difference between $? in shell and perl programming

what is the difference between $? in shell and perl programming.Can u guide me to any links which tells more abt it.Thnks in advance.
2 REPLIES 2
Oviwan
Honored Contributor

Re: difference between $? in shell and perl programming

Hey

Perl: (from http://www.sarand.com/td/ref_perl_reserve.html)
$? The status returned by the last pipe close, backtick ( `` ) command, or system() operator. Note that this is the status word returned by the wait() system call, so the exit value of the subprocess is actually ( $? >> 8 ). Thus on many systems, $? & 255 gives which signal, if any, the process died from, and whether there was a core dump.
Also: $CHILD_ERROR

Shell: (from http://snap.nlc.dcccd.edu/reference/sysadmin/julian/ch16/324-326.html)
$? Bourne or Korn shell: Return the exit status (in decimal) of the last command executed. Most commands return a zero exit status if they complete successfully; otherwise a non-zero exit status is returned. This variable is set after each command is executed.
C shell: Check to see if a variable of that name has been set.

Regards

p.s. I have assigned points to 4 of 33 responses to my questions. So, don't forget to assigne points...
Steven Schweda
Honored Contributor

Re: difference between $? in shell and perl programming

> [...] (in decimal) [...]

Really? Amazing.