Hi all,
I have a requirement to connect DB2 database and do some operations and generate a report through shell script.
Can anyone please tell me how can i connect DB2 from unix shell script?
Thanks in ADV.
Hi all,
I have a requirement to connect DB2 database and do some operations and generate a report through shell script.
Can anyone please tell me how can i connect DB2 from unix shell script?
Thanks in ADV.
# Establish DB connection
ret=`db2 connect to $1`
ret=`echo "$ret"`
if [[ -z $ret ]] then
echo "Error connecting to $1 database."
exit 1
else
echo "Successfully connected to $1 database !"
fi
# Terminate DB connection
ret=`db2 terminate`
ret=`echo "$ret" | grep DB20000I | cut -c1-8`
if [[ $ret = "DB20000I" ]] then
echo "The TERMINATE command completed successfully."
fi
$1 is your DB name as argument
Hope this helps you!
Thank you very much......