I have written the following function in unix shell script to validate SQL*PLUS login and throw a user-defined message.
function check_db_conn
{
exit| sqlplus -s -L $User/$Password@$SID > /dev/null
if [[ $? -ne 0 ]]; then
echo "Incorrect DB credentials"
fi
}
However, I want to modify this function so that in case user has entered correct login but there is some issue with TNS listener it should display appropriate message.