The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-24-2008
ashok2008 ashok2008 is offline
Registered User
 

Join Date: Apr 2008
Posts: 1
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.
Reply With Quote
Forum Sponsor