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 in SFTP vikramsnest Shell Programming and Scripting 1 08-15-2007 11:08 PM
Explanation for the exit codes 2 sesedada UNIX for Advanced & Expert Users 1 06-24-2006 11:31 PM
Catching all Exit Codes Sivaswami J Shell Programming and Scripting 3 02-16-2006 03:13 PM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 02: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 (permalink)  
Old 04-04-2008
cmschube's Avatar
Registered User
 

Join Date: Apr 2008
Location: Iowa
Posts: 1
Post 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 [ (result of uvscan) = x ]; then
echo "This is why it quit"

Here's what I have so far..
Code:
If [[ `pgrep $PROC` = 0 ]] ; then
	pkill uvscan 
Elseif
	[[ 'pgrep $PROC' = 1 ]] ; then
	nohup $UVSCAN_PATH/uvscan -c -f $DIRECTORIES -d $DAT_PATH -m $QUARANTINE -r --secure
After this last command is where I want to make a sub (?) routine of ifs/thens depending on how the command exits.

I hope someone can help me out here? Or am I way in left field?

Thanks from a new user,

cmschube

Last edited by Yogesh Sawant; 04-04-2008 at 05:34 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-04-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,965
An example:

Code:
if pgrep something > /dev/null 2>&1 ; then
  #do something here
elif "something else" ; then
  #do something else here
else
  #do all other things here
fi
Read the manpage of ksh or Google for "ksh scripting".

Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:26 PM.


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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0