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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Exception Handling bertpereira Shell Programming and Scripting 5 01-14-2009 09:28 PM
shell programs rameshparsa Shell Programming and Scripting 1 11-17-2005 10:07 PM
Linux g++ 2.95.3 exception handling earl High Level Programming 0 08-16-2005 02:46 PM
exception handling RichardS UNIX for Advanced & Expert Users 1 06-16-2004 06:29 PM
different shell programs,processes ramyar UNIX for Dummies Questions & Answers 1 12-19-2001 06:45 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 08-25-2008
chaitu_inmage chaitu_inmage is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
Question Exception-handling in Shell programs

Hi all,

I am writing a set of scripts and some of these are nested within others. I want to be able to execute a single high-level script at the command-line, which in turn may invoke other scripts as required, and when a failure occurs in any of the nested scripts, I want to be able to track the deepest-nested command causing the failure and preferably a call trace.

To do this, trap could be used I was told but I am not sure trap's functionality is enough for my need. What do you think is the best way here?

It's a constraint at this place that I use only shell and not a full-blown programming language. Any help from you guys is greatly appreciated.

Best Regards,
Chaitanya
  #2 (permalink)  
Old 08-25-2008
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Will each of the scripts that you invoke be doing detailed error checking? If the last script executed runs a command that fails, it could print the error and return a failure code.

If you write each script to do that, your trace takes care of itself, without any additional effort required (other than what you need to put in for the scripts themselves).
  #3 (permalink)  
Old 08-25-2008
chaitu_inmage chaitu_inmage is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
Question

Hi blowtorch,

No, I wasn't planning on putting detailed error checks in each of the scripts...they are too long (5000+ lines) and doing that that would take me forever. I am looking more from a less-involved solution. Do you think it's possible actually? Something like - (I am vague I know but it's the best I can do!) -

1. Start a guarded environment at the beginning of each script (guarded as in - each command is executed and if it succeeds, alright; otherwise, break the whole program right there).

2. Execute each command in the script (without explicitly coding for error-checking, i.e.)

3. Run an event like trap in case of failure, and fire an email.

What do you say...?
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 03:33 AM.


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