Error Handling in Korn Shell scripts


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Error Handling in Korn Shell scripts
# 1  
Old 08-29-2005
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
# 2  
Old 09-02-2005
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 09:50 AM..
# 3  
Old 09-02-2005
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 09:50 AM..
# 4  
Old 09-02-2005
Bakunin - please refrain from profanity. Thanks. (Edited both post and changed the offending word)
# 5  
Old 09-06-2005
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Handling scripts in two different servers

Hi , My Script work as below 1- On server 1 execute script1.sh , through this script one parameter file is generated as file.txt this is to transfer on server 2 2- After reaching on server2 other shell script script2.sh execute using parameter file file.txt This generate file... (1 Reply)
Discussion started by: kaushik02018
1 Replies

2. Shell Programming and Scripting

[Solved] How to refer more than 9 command line inputs for a scripts in korn shell?

Hi all, I have a script which should take more than 9 command line inputs while running. Likescript.sh a s d f g h j j k l o p i u y t r e w Now in the script if I have to access one of the input which is at position after 9, in this case say 'p' then how can I do that? echo $12 will not work... (15 Replies)
Discussion started by: pat_pramod
15 Replies

3. Shell Programming and Scripting

Not able to capture sftp error in Korn Shell

I am not able to capture error condition in sftp in Korn Shell #!/bin/ksh sftp batch@uat >abc 2>&1 << ENDFILE cd public put /data/WELCOME_55 ENDFILE ret_val=$? if ] then print file "copied successfully" else print file "NOT copied successfully" fi return 0 Now the... (9 Replies)
Discussion started by: Soham
9 Replies

4. Shell Programming and Scripting

korn shell script executed with error

Hi, need help, I would like to know what is this IF statement trying to do? When the script is executing and error out with line 9 which is the IF statement line. if ] then TOPDIR=$(pwd) else TOPDIR=${0%/*} fi TOPDIR=${TOPDIR%/*} the log file. Current system time is... (15 Replies)
Discussion started by: beooi
15 Replies

5. Shell Programming and Scripting

Advanced error handling in shell scripts

Hi all I've got a question regarding error handling in shell scripts. My background is mainly object oriented programming languages, but for a year or so I've been doing more and more (bash) shell scripting (which I quite enjoy by the way). To handle errors in my scripts I... (3 Replies)
Discussion started by: script_man
3 Replies

6. Shell Programming and Scripting

Error handling in Unix shell scripting

Hello, I have written a shell script and suppose there is any error in the script. How i can do exception handling in shell script.for example i have below code sqlplus -s <<uid>>/<<pwd>>@<<$ORACLE_SID>> <<EOF > 1_pid1.log set pagesize 0 set feedback off set heading off set linesize 200... (1 Reply)
Discussion started by: rksingh003
1 Replies

7. Shell Programming and Scripting

Error with korn shell - arrays

Hi All I have a FTP script which FTPs few files into an user folder. I intend to keep track of the folder size before FTP and after FTP and print that once the FTP script is run (a kind of comparison, "Before FTP, "After FTP"). I decided to use kron shells to accomplish this. #! /bin/ksh ... (2 Replies)
Discussion started by: guruparan18
2 Replies

8. Shell Programming and Scripting

Korn Shell Script to find out error in logfile

Hi All, I am new to this forum as well as to unix scripting. Can you please help me to create a korn shell script to find out errors in logfiles and get the name of that logfile ( which is having error) in email and email it to me? (2 Replies)
Discussion started by: jithu
2 Replies

9. UNIX for Dummies Questions & Answers

Handling Errors in Shell Scripts

I have a shell script, which calls a load script to load a database. How can i handle errors in Unix(similar to 'error level' in Batch scripts)? I am trying to use 'mailx' to send a Success/failure message based on the error level returned by the load script. I have already used an error log... (2 Replies)
Discussion started by: sarsani
2 Replies

10. Shell Programming and Scripting

Null handling in scripts

Hi, I face some problem with handling of nulls. I declare a variable - say i - and intialise to 0. Later I read it from console, wherein if I dont give any variable and press return key, I get this error: "0403-004 Specify a parameter with this command" Is there anyway to handle this error? ... (3 Replies)
Discussion started by: mohanprabu
3 Replies
Login or Register to Ask a Question