UNIX for Advanced & Expert Users

Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Error Handling in Korn Shell scripts

👤 Login to reply

    #1  
Old 08-29-2005
bhgopi bhgopi is offline
Registered User
 
Bug Error Handling in Korn Shell scripts

Hi,

I am using few ISQL statements to update and delete from a few tables in sybase, now i want to roll back the transaction when any of the statements fail.How i can i capture these errors in the shell scripts.Please advise.

Thanks,
Gopi
Sponsored Links
    #2  
Old 09-02-2005
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
catch the errorlevel of the command:

[code]
...
/path/to/somecommand ; RC=$?
if [ $RC -eq 0 ] ; then
print - "everything worked out fine"
else
print - "something screwed up"
fi
[code]

The errorlevel is set anew for every command issued, so be sure to get it as soon as the program in question is finished.

bakunin

Last edited by RTM; 09-02-2005 at 08:50 AM..
Sponsored Links
    #3  
Old 09-02-2005
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Quote:
Originally Posted by bakunin
[code]
...
/path/to/somecommand ; RC=$?
if [ $RC -eq 0 ] ; then
print - "everything worked out fine"
else
print - "something screwed up"
fi
[code]

bakunin
I agree its only a print.. but it is against point 1 of this post ?

Last edited by RTM; 09-02-2005 at 08:50 AM..
    #4  
Old 09-02-2005
RTM's Unix or Linux Image
RTM RTM is offline Forum Advisor  
Registered User
 
Bakunin - please refrain from profanity. Thanks. (Edited both post and changed the offending word)
Sponsored Links
    #5  
Old 09-06-2005
denverd0n denverd0n is offline
Registered User
 
Checking the return code won't help. What bhgopi wants to do is rollback the transaction within Sybase. By the time you get the Unix return code the transaction is already committed.

Bottom line: You have to check the results and do the rollback or commit entirely from within isql. You probably should be asking this question on a Sybase forum, rather than Unix.
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Advanced error handling in shell scripts script_man Shell Programming and Scripting 3 10-21-2009 07:50 AM
Error handling in Unix shell scripting rksingh003 Shell Programming and Scripting 1 09-04-2009 10:55 AM
Error with korn shell - arrays guruparan18 Shell Programming and Scripting 2 08-21-2008 10:38 AM
Handling Errors in Shell Scripts sarsani UNIX for Dummies Questions & Answers 2 12-24-2006 09:16 AM



All times are GMT -4. The time now is 09:46 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?