The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
exit codes from rexec? diego_sapphire UNIX for Dummies Questions & Answers 4 05-04-2009 11:44 AM
Exit Codes cmschube Shell Programming and Scripting 1 04-04-2008 11:34 AM
Exit codes in SFTP vikramsnest Shell Programming and Scripting 1 08-16-2007 02:08 AM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 06:08 PM
exit codes donna carter High Level Programming 3 05-31-2001 09:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2006
Sivaswami J Sivaswami J is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 1
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 ?
  #2 (permalink)  
Old 02-16-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Introduce a function to catch all the exit codes.

Something like

Code:
 
EXIT_CODE=""

function assembleExitCode
{
EXIT_CODE="${EXIT_CODE} $@"
}
At every place where you are looking for an exit code, invoke the function as
Code:
assembleExitCode $?
At the end of the code,

Code:
if [[ x"$EXIT_CODE" != x ]] ; then
echo "Mail status"
fi ;
  #3 (permalink)  
Old 02-16-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
Try this

case $? in
1) echo "Exit message1";;
2) echo "Exit message2";;
.
.
.
esac
  #4 (permalink)  
Old 02-16-2006
bigearsbilly bigearsbilly is offline
Registered User
  
 

Join Date: Feb 2006
Location: Southern England
Posts: 102
trap "command" EXIT


man ksh trap
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0