The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Exit Codes cmschube Shell Programming and Scripting 1 04-04-2008 08:34 AM
bash awk codes to perl phamp008 Shell Programming and Scripting 1 03-15-2008 02:11 AM
difference b/t the exit codes $* and $@ praveen_b744 Shell Programming and Scripting 1 09-19-2007 06:53 AM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 03:08 PM
exit codes donna carter High Level Programming 3 05-31-2001 06:35 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-25-2005
Registered User
 

Join Date: Oct 2005
Posts: 86
How to get exit status codes in bash from Perl?

I apologize if I have already posted this query. I scanned back quite a few pages but could not find such a query.

If my perl code contains "exit(33)" how can I get that value in bash for use in a "if" statement.

Thanks,
Siegfried
Reply With Quote
Forum Sponsor
  #2  
Old 10-25-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
echo "${?}"
Reply With Quote
  #3  
Old 10-26-2005
Registered User
 

Join Date: Jul 2005
Location: England
Posts: 183
To expand, all unix shells set a particular variable '$?' to the the exit status of the command just completed. So in your case:

Code:
my_perl_prog.pl

if [ $? -eq 33 ]
then
  <do something>
fi
Reply With Quote
  #4  
Old 10-26-2005
Registered User
 

Join Date: Oct 2005
Posts: 86
web page for bash documentation?

OK thanks! $? is for the return status code, $! is for PID. Is there a web page where these single character variables are documented? How about a man and info page too?

This is beginning to look a lot like perl. I bet $$ is the current PID.

Thanks,
Siegfried
Reply With Quote
  #5  
Old 10-26-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,681
Under man sh, section Special Parameters
Under man ksh, section Parameters
Reply With Quote
  #6  
Old 10-26-2005
Registered User
 

Join Date: Jul 2005
Location: England
Posts: 183
man <your shell name>

for example

man bash
man ksh
man sh

should tell you all you need to know ... and strictly speaking it's perl that looks like the shells not the other way round :-). Otherwise google should return a wealth of information
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0