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 ?

Try to replace

NO=`echo $COUNT | grep "CT-LIBRARY error" | wc -l `
echo $NO
if [ "$NO" -eq "1" ]; then 
break;
fi

by :

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

Jean-Pierre.

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