Hi there,
im trying to send a mail to dba support in case database is down.
The thing is that when i am executing the script its giving me error.
i tried to look it on google but of no use.
below is the code:
DBALIST="dbasupport@hdfecrgo.com";export DBALIST
export PATH=/usr/bin:/usr/sbin
if [ -f /usr/bin/less ]; then
export PAGER="/usr/bin/less -ins"
elif [ -f /usr/bin/more ]; then
export PAGER="/usr/bin/more -s"
fi
case ${SHELL} in
*bash)
typeset +x PS1="\u@\h:\w\\$ "
;;
esac
export ORACLE_HOME=/oracle11/home/app/oracle11/product/11.2.0/dbhome_1
export ORACLE_BASE=/oracle11/home/app/oracle11
export TNS_ADMIN=/oracle11/home/app/oracle11/product/11.2.0/dbhome_1/network/admin
PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export LD_LIBRARY_PATH
sqlplus -s user/mypassword@mydb >> /tmp/alert.txt
var=`grep -q 'ORA-' '/tmp/alert.txt'`
if [ $var == 0 ]; then
mailx -s "Database instance test is down" dbasupport@hdfcergo.com
fi
OUTPUT:
oracle11 /oracle11/home> sh test.sh
<=================also here i have to press three times and still it does not send mail
test.sh[23]: test: 0403-004 Specify a parameter with this command.
my log file:
oracle11 /oracle11/home> cat /tmp/alert.txt
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
My Goal is to send mail when if found the database down.
can any one look into it where i am wrong ???
thanks