I haven't coded in ksh in forever and this script is proving me not a great coder. I keep getting unexpected end of file when I try to execute this...Line 94 is the last line of the code..
#!/usr/bin/ksh
. /home/oraprod/.bash_profile
DBSID=prod # Database sid
CONNECTSTR=apps/xxxxxxxx@prod # Connect string prod
MAILADR=dba@group.com # mail
ACCEPTLAG=2 # allowed difference
# set the environment to the standby database
export ORACLE_SID=prod
export ORACLE_HOME=/u02/app/proddb/10.1.0.5
export PATH=$PATH:$ORACLE_HOME/bin
# declare functions to query v$archived_log and other checks
runsqlstb()
{
sqlplus -S <<EOF
/ as sysdba
set heading off
select max(sequence#) from v\$archived_log where applied='YES' and dest_id=2 ;
exit
#EOF
}
runsqlprd()
{
sqlplus -S ${CONNECTSTR} <<EOF
set heading off
select max(sequence#) from v\$archived_log;
exit
# EOF
}
mailme()
{
if [ ${LAGDIFF} -gt ${ACCEPTLAG} ]
then
echo
echo The ${DBSID} standby database lacks behind too far.
echo logseq ${DBSID} production database is $NUMBERPRD >> mailtempl
echo logseq ${DBSID} standby database is $NUMBERSTB >> mailtempl
echo
mailx -s "Standby database out of sync " ${MAILADR} < mailtempl
rm mailtempl
fi
}
errtrap()
{
#echo Fout in script > mailtempl
mailx -s "Fout in script " ${MAILADR} < mailtempl
rm mailtempl
}
################### MAIN ######################################
NUMBERSTB=`runsqlstb`
if [ $? -ne 0 ]
then
echo "Something wrong with Standbyi" ${DBSID} > mailtempl
errtrap
fi
NUMBERPRD=`runsqlprd`
if [ $? -ne 0 ]
then
echo "Something wrong with" ${DBSID} > mailtempl
errtrap
fi
echo standby database is ${NUMBERSTB}
echo production database is ${NUMBERPRD}
LAGDIFF=`expr ${NUMBERPRD} - ${NUMBERSTB}`
mailme
"standby_monitor2.sh" 93L, 2416C written
[prod@kfc52d : prod ] > ./standby_monitor2.sh
./standby_monitor2.sh: line 94: syntax error: unexpected end of file