How to get exit status codes in bash from Perl?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get exit status codes in bash from Perl?
# 1  
Old 10-25-2005
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
# 2  
Old 10-25-2005
echo "${?}"
# 3  
Old 10-26-2005
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

# 4  
Old 10-26-2005
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
# 5  
Old 10-26-2005
Under man sh, section Special Parameters
Under man ksh, section Parameters
# 6  
Old 10-26-2005
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ignore exit status for #!/bin/bash -e

I have a file /u/setuplink.txt more setuplink.txt ln -s /u/force.sh stopf.sh ln -s /u/tnohup.sh tnohup.sh ln -s /u/quick.sh startquick.sh more runstat.sh #!/bin/bash -e echo "START" /u/setuplink.txt echo "END" i wish to exit the runstat.sh for any errors except if the link... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Perl Question Grep and exit status

Im being forced to write in perl. I prefer KSH or Expect, so I suppose its time to become more fluent with perl. I have the following problem. I want to loop through Filea and check that each line in Filea is resident in Fileb. Filea contents two four six eight houseboat Fileb... (4 Replies)
Discussion started by: sumguy
4 Replies

3. Shell Programming and Scripting

Bash Shell Script Exit Codes

Here is my daily stupid question: How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return... (6 Replies)
Discussion started by: metallica1973
6 Replies

4. Linux

Exit codes

I am trying to run this SH on Linux and getting error at IF condition. I want to read the EXIT code and send the failure or success message. Please help me on this. This worked when i was running on Solaris. #!/bin/bash $ORACLE_HOME/bin/sqlplus abc/xyz@qwe @/home/test.sql if ;... (4 Replies)
Discussion started by: rlmadhav
4 Replies

5. Shell Programming and Scripting

Exit Codes

Good Morning All.. I was wondering about getting exit codes of a command in a shell script. I'm trying to run uvscan (McAfee command line scanner) and I want to have the log file say why, if at all, the process failed/exited. Something to the extent of If ; then echo "This is why it... (1 Reply)
Discussion started by: cmschube
1 Replies

6. Shell Programming and Scripting

bash awk codes to perl

Hi, I am interesting in writing the following bash codes into perl My script is simple take field 2 in /etc/passwd and put into an array #!/bin/bash PASSWD_FILE=/etc/passwd A=(`awk -F: ' { print $2 }' $PASSWD_FILE `) Can someone give me equivalent codes in perl ? (1 Reply)
Discussion started by: phamp008
1 Replies

7. UNIX for Advanced & Expert Users

Explanation for the exit codes 2

Hi, Can anyone give me the explanation for the exit codes 1 and 2 returned from Korn shell. Thanks in advance. (1 Reply)
Discussion started by: sesedada
1 Replies

8. Shell Programming and Scripting

Catching all Exit Codes

I have a Unix Script that has several exit in the middle. each returning seperate exit codes. I have to catch all the exit's and perform an operation say "Mail the status code" before the actual code completes. How can i do this in KSH ? (3 Replies)
Discussion started by: Sivaswami J
3 Replies

9. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies

10. Programming

exit codes

Where can a locate a list of Unix exit codes? thank you, Donna (3 Replies)
Discussion started by: donna carter
3 Replies
Login or Register to Ask a Question