![]() |
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 and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to detect failure from batch SFTP and SHELL operations | chengwei | Shell Programming and Scripting | 2 | 05-28-2008 07:32 AM |
| copy command failure | mynix | Shell Programming and Scripting | 1 | 12-16-2007 12:35 AM |
| find command to detect installations | goldenglobe | UNIX for Dummies Questions & Answers | 2 | 06-13-2007 10:06 AM |
| Automatically executing a command | robbiegregg | UNIX for Dummies Questions & Answers | 8 | 04-06-2005 11:46 AM |
| failure of at command | DKuester | UNIX for Dummies Questions & Answers | 5 | 10-10-2003 12:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
How to automatically detect command failure
I have a shell script. In this script I executes various command and my requirement is such that if any command fails I've to terminate the shell script.
To achieve this objective I'm checking the value of $? after each command and if its value is greater thaen I 'exit' the script. Is there any way through which I can avoid the if condition on $? after each and every command as It a pain to put if condition after every command. |
|
||||
|
Code:
set -e It's more picky than you think, so a script which was not written to cope with this probably has unchecked commands which might bite you in the back. (It's good for the self-discipline, of course.) For example, anything like hello && echo success will terminate the script if hello fails. You need to rewrite that as an if ... then, or artificially add || true at the end. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|