I made a script to check tnsping but the if statement does not working properly. The following is the script:
ping=$(tnsping oracle1 |grep OK| awk -F" " '{print $1 }')
if [ -n $ping ]
then
echo "OK"
else
echo "NOT OK"
fi
If a execute change oracle for a non-existing oracle server I also receive "OK".
-n = The length of STRING is greater than zero