crazywolf2010
asked on
Shell Script Help : [ Error -gt: unary operator expected ]
Gents,
I am trying to get a SHELL script working .
It is spitting error
[oracle@scripts]$ ./dg.sh
./dg.sh: line 39: [: -gt: unary operator expected
./dg.sh: line 43: [: -gt: unary operator expected
I am trying to get a SHELL script working .
It is spitting error
[oracle@scripts]$ ./dg.sh
./dg.sh: line 39: [: -gt: unary operator expected
./dg.sh: line 43: [: -gt: unary operator expected
#!/bin/bash
#set Oracle environment for Sql*Plus
ORACLE_HOME=/u01/app/oracle/product/ 10.2.0 ; export ORACLE_HOME
ORACLE_SID=pegaprod ; export ORACLE_SID
PATH=$PATH:/u01/app/oracle/product/1 0.2.0/bin
#set working directory. script is located here..
cd /home/oracle/scripts
#Problem statement is constructed in message variable
MESSAGE=""
#hostname of the primary DB.. used in messages..
HOST_NAME=`hostname`
#who will receive problem messages.. DBAs e-mail addresses seperated with space
# DBA_GROUP='dba1@company.com dba2@company.com'
#SQL statements to extract Data Guard info from DB
LOCAL_ARC_SQL='select archived_seq# from V$ARCHIVE_DEST_STATUS where dest_id=1; \n exit \n'
STBY_ARC_SQL='select archived_seq# from V$ARCHIVE_DEST_STATUS where dest_id=2; \n exit \n'
STBY_APPLY_SQL='select applied_seq# from V$ARCHIVE_DEST_STATUS where dest_id=2; \n exit \n'
#Get Data guard information to Unix shell variables...
LOCAL_ARC=`echo $LOCAL_ARC_SQL | sqlplus -S / as sysdba | tail -2|head -1`
STBY_ARC=`echo $STBY_ARC_SQL | sqlplus -S / as sysdba | tail -2|head -1`
STBY_APPLY=`echo $STBY_APPLY_SQL | sqlplus -S / as sysdba | tail -2|head -1`
#Allow 20 archive logs for transport and Apply latencies...
let "STBY_ARC_MARK=${STBY_ARC}+20"
let "STBY_APPLY_MARK= ${STBY_APPLY}+20"
if [ $LOCAL_ARC -gt $STBY_ARC_MARK ] ; then
MESSAGE=${MESSAGE}"Error on $HOST_NAME Standby -log TRANSPORT- service! \n local_Arc_No=$LOCAL_ARC but stby_Arc_No=$STBY_ARC \n"
fi
if [ $STBY_ARC -gt $STBY_APPLY_MARK ] ; then
MESSAGE=${MESSAGE}"Error on $HOST_NAME Standby -log APPLY- service! \n stby_Arc_No=$STBY_ARC but stby_Apply_no=$STBY_APPLY \n"
fi
if [ -n "$MESSAGE" ] ; then
MESSAGE=${MESSAGE}"\This problem may cause the archive directories to get full!!! \n .\n "
echo $MESSAGE
fi
Do you have values in each of your variables?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent work by MikeOM_DBA.
...
...
echo STBY_ARC $STBY_ARC
echo STBY_APPLY $STBY_APPLY
echo STBY_ARC_MARK $STBY_ARC_MARK
echo STBY_APPLY_MARK $STBY_APPLY_MARK
if [ ...
...
wmp