# 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"
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.