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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Detemine if SED is successful gugs Shell Programming and Scripting 1 07-30-2008 04:40 AM
TAHI Test Suite 4.0.2 (Self-Test Test Suite branch) iBot Software Releases - RSS News 0 07-10-2008 06:50 AM
TAHI Test Suite 3.0.15 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 07-10-2008 06:50 AM
TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 04-06-2008 12:20 PM
Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com iBot UNIX and Linux RSS News 0 07-23-2007 10:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
Prashantckc Prashantckc is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 18
Test if execution was successful

Hi
How can I test inside a shel script whether the last action was successful or not.

I have the following line which is executing inside a script

. ./runProcess.sh $i $var_num>> error.txt 2>&1

This is occuring in a loop. How can i test whether it was succes for last var_num or not. How can I check that?
  #2 (permalink)  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If runProcess is competently written, it will set its exit code to non-zero if it fails.

Code:
if ./runProcess.sh whatever; then
  : success, do nothing
else
  echo "eek, failed with exit code $?" >&2
  blink
  wave hands --left --right
  blink
fi

Last edited by era; 10-08-2008 at 08:15 AM.. Reason: Add sample code
  #3 (permalink)  
Old 10-08-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Be careful with the application that masks the return code with the success status of the shell from which its executing.

For example : If ftp's connection to a ftp server is not successful it will still return 0 to $? due to the reason ftp command completed successfully
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 12:02 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