![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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? |
|
||||
|
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 |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|