How to handle errors and warnings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to handle errors and warnings
# 1  
Old 10-18-2010
How to handle errors and warnings

Hi Guys,
I am working on a shell script(main script) where in i have to call another script B and pass parameter to that script. I see that the shell script that is being called in the main script is throwing warnings/fatal errors. So i am just wondering how do i capture these and ask the script to exit when there are any warnings/fatal errors.
FYI...i am calling this script B three times in the main script...once for retrieving (parameter 1)the data, then for update(paramter 2) and then for storing(paramter 3) the data. If there are warnings/errors in any of these steps, they should be captured and the script should exit instead of going further.

Thanks in advance!!
# 2  
Old 10-19-2010
The simplest way is to catch the exit code of script B.
Put this line in your 'main' script just after you call script B
Code:
#Main Script
./scriptB
EXIT_CODE=`echo $?`
if [ $EXIT_CODE -ne 0 ]
then
    echo "Script B did not execute successfully. Exiting..."
    exit 1
fi


Last edited by umar.shaikh; 10-19-2010 at 02:55 AM.. Reason: Making the script more understandable :)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

2. Shell Programming and Scripting

Need help to handle errors during SFTP

Hi, I have written a script that sftp's files from linux box to a IBM machine. Can anybody help me how to handle any errors during SFTP file transfer. I am writing the SFTP commands onto a file and executing that as you can see below. while read line do if ] && ]; then echo "put... (1 Reply)
Discussion started by: ramkiran77
1 Replies

3. UNIX for Dummies Questions & Answers

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (1 Reply)
Discussion started by: pink01
1 Replies

4. UNIX for Advanced & Expert Users

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (0 Replies)
Discussion started by: pink01
0 Replies

5. Shell Programming and Scripting

How to handle errors during script execution

Hi I have written a script which returns a number. This resulting number I assign to the variable for example: $ A=`get_dbnum 118 ttrn` $ echo ${A} 8208 $ The script becomes interective once the error occures and the number is not found. It prompts the user to enter the number. The... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. AIX

Warnings in AIX

Dear experts, please help in this regard, when i am trying to compile some files for 64 bit in AIX, iam getting this warning "/usr/include/alloca.h", line 34.9: 1540-1401 (I) An unknown "pragma __alloca" is specified. how to solve this warning , what is the significance of this please... (1 Reply)
Discussion started by: vin_pll
1 Replies

7. Solaris

Not getting warnings!!

I have tried to compile the code on solaris which is bash-3.00$ uname -a SunOS zen 5.7 Generic_106541-37 sun4u sparc SUNW,Ultra-80 bash-3.00$ CC -V CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0 when I compile just a simple program, int main() { long kk = 200; int jj = kk; return... (0 Replies)
Discussion started by: amit_27
0 Replies

8. Shell Programming and Scripting

prevent errors/warnings from being written to log file

i have this script which works fine but shows errors when it runs..these are more like warnings and the script runs fine.. i am on a sun machine.. i know it writes all the error messages to a master log file.. is there any way i can turn off these warnings/error messages and prevent them from being... (2 Replies)
Discussion started by: npatwardhan
2 Replies

9. Shell Programming and Scripting

how to handle sql loader errors in unix

hi all, how to handle sql loader errors in unix shell ?? thanks in advance gemini (3 Replies)
Discussion started by: gemini106
3 Replies

10. AIX

Sysback Warnings

I am currently running backups using an entry in the crontab redirection the output to a file. From time to time I get a backup complete with Warnings but don't know what the warnings are and they don't appear in the file. Where can I view the warings? Is there a command to view the warnings? ... (2 Replies)
Discussion started by: daveisme
2 Replies
Login or Register to Ask a Question