LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2006, 06:08 AM   #1
reach2tripplek
LQ Newbie
 
Registered: May 2006
Posts: 2

Rep: Reputation: 0
exception handeling in script


Hi guys
I want to write a shell script chkerror.sh which will check for command error and exception in other shell script to which i have to test or debug .and will display error message on terminal by stopping the execution of script.
Can anybody guide me how to do that .

Will it be possible to use a global variable and function in each script to which i have to test instead of running a script.

Waiting for ur needful reply
Kamal

Last edited by reach2tripplek; 05-01-2006 at 07:41 AM.
 
Old 05-02-2006, 02:26 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In Unix, if all is well after a cmd, $? is usually set to zero, so the std test is:
Code:
rslt=`cmd`
if [[ $? -ne 0 ]]
then
    error occurred, send msg etc
fi
where cmd is the other prog. If it doesn't handle its own stdout/stderr, you can redirect those here or capture them for debug.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling vipinsharma Programming 2 09-25-2005 11:05 AM
help createing exception class from base STL exception qwijibow Programming 4 04-20-2005 05:23 AM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM
SuSE package handeling system santiagosilva Linux - Newbie 0 02-14-2004 02:20 AM
Runtime Exception vs. Exception mikeshn Programming 1 09-22-2002 05:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration