Error Checking in Shell scripts.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error Checking in Shell scripts.
# 1  
Old 05-20-2009
Error Checking in Shell scripts.

What i need to do is when the database connection is not successful , the script should move to next list i.e skip the current.
But when i do this -

if [ "$NO" -eq "1" ]; then
break;
fi

The script break but it goes to the condition -

if [ $COUNT -ne 0 ]; then


for LIST in $LISTS
do
for TABLE in $TABLES
do
COUNT=`/usr/local/sybase1251/OCS-12_5/bin/isql -S $LIST-U user -P pass-w 100 <<EON | egrep -v -e '-----------' | egrep -v -e 'affected'
select count(*) from Table
go
EON`
NO=`echo $COUNT | grep "CT-LIBRARY error" | wc -l `
echo $NO
if [ "$NO" -eq "1" ]; then
break;
fi

if [ $COUNT -ne 0 ]; then
#TABLES="$CLIENT $TABLE $COUNT\n"$TABLES
fi
done
done


How can i get this working ?
# 2  
Old 05-20-2009
Try to replace
Code:
NO=`echo $COUNT | grep "CT-LIBRARY error" | wc -l `
echo $NO
if [ "$NO" -eq "1" ]; then 
break;
fi

by :
Code:
if echo $COUNT | grep 'CT-LIBRARY error' ; then
   break
fi

Jean-Pierre.
# 3  
Old 05-20-2009
Got it sorted

if [ $ERROR -gt 0 ]; then
echo "Failed to Connect to " | /usr/ucb/Mail -s "Failed to Connect to $CLIENT" mail@yahoo.com
break;
elif [ $COUNT -ne 0 ]; then
echo "Hello\n";
fi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help me with C-shell Script: Disk checking

Hi, i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : 100.21.25.12 cal 4 : 100.21.25.14 and so on... Right now, i have this. #! /bin/csh -f ... (0 Replies)
Discussion started by: lattey
0 Replies

2. Shell Programming and Scripting

Shell scripts error

Dear all I have shell script where files have been organized into directory, i pass the directory name and it shold pick all the files within the directory and move to differnet path. When i run the scripts it doesn't move and come out with error and i am not able to understand it the... (2 Replies)
Discussion started by: guddu_12
2 Replies

3. HP-UX

Scripts to move files via FTP with error checking

Hi Members, Can members please advise or suggest how to write UNIX script which move all zip files in source directory and when done delete zip files from source directory? We want to delete only on successful transfer to the destination. secondly want to add some error checking if the FTP... (1 Reply)
Discussion started by: dxj0815
1 Replies

4. Shell Programming and Scripting

Getting error in shell scripts

Hi, I have a shell script confug-msys.sh which callls config-common.sh. When run from command prompt,these work fine but give the below error when i try to run from code-blocks line 7: --without-contrib: command not found ...Also I am unable to understand what the second script does...... (4 Replies)
Discussion started by: binnyshah
4 Replies

5. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

6. 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

7. Shell Programming and Scripting

Checking passwords - scripts

Hi Unix experts.... I am in the process checking user and root password of more than 1000 servers manulay. I am very pissed of checking these many servers manualy. Could some one of you help me how can i check the passwords just by runing some scripts..! Need Help Guys..! :confused: (5 Replies)
Discussion started by: bullz26
5 Replies

8. UNIX for Advanced & Expert Users

QA checking for shell scripts

Hi all Does the notion of QA make sense when talking about shell script development? I would like to put in place such a QA procedure to ensure the code we provide is full compliant with certain norms we think are right. I just thought it would be a good idea to ask the community about the... (7 Replies)
Discussion started by: Indalecio
7 Replies

9. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

10. UNIX for Advanced & Expert Users

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 (4 Replies)
Discussion started by: bhgopi
4 Replies
Login or Register to Ask a Question