Connect status of db2 in Unix shell script

Hi

I am trying to connect to db2 database from Unix shell script (k shell)

I need to catch the status of connect whether it is succesful or not.

----------------------------------------------------------

# Read login credentials for db2
tput clear
echo "Please enter your Userid:\c"
read uid
echo "Please enter your Password:\c"
read pass
db2 "connect to XYZDB user $uid using $pass" 

----------------------------------------------------------

Thanks in advance
Karri Mohan

The first db2 creates a personal daemon process to hold onto the connection and take the series of db2 command chunks (do ps -ef after the first to see). Once you connect, you can run more db2 commands to see if it is happy, usually by using it. Try a bogus user id and see if the first DB2 tells you that you have no connection. Maybe there is a verbose mode to get it to verify it is nominally connected. I forget the details, and do not have db2 on this gig.

I was able to validate like this

#Validate login credentials
if [ $? -ne 0 ]; then
 echo""
 echo "Please enter valid username/password"
 exit 0
fi

I'm confused, but I do not have db2 manuals handy to know what returns happen for connect.