I want to catch the login failed in my shell script
Code looks like below
retval=`isql -S$envServer -U$GCMS_USERNAME -h -b << ENDSQL | grep -vE "^Password: $"
$GCMS_PASSWORD
set nocount on
GO
USE "mydb"
GO
USE "SELECT tname from MYTABLE"
GO
ENDSQL`
echo retval
So if Login fails i get Msg 4002, Level 14, State 1: Server 'MYSERVER': Login failed. CT-LIBRARY error: ct_connect(): protocol specific layer: external error: The attempt to connect to the server failed.
I want to catch this, so when this error comes is do exit and if it is sucess i can perform my other operations.
A quick test for the
Msgstring:If the data from
MYTABLEcould contain the stringMsgyou can expand the test to a pattern that's sufficiently unique to match on just errors: