Home » Infrastructure » Unix » Need help with if statement
Need help with if statement [message #254076] Wed, 25 July 2007 12:48 Go to next message
toshidas2000
Messages: 120
Registered: November 2005
Senior Member
echo
timeecho "VERIFY LOGFILE FOR NOTIFICATION"
echo

subject="Logfile Status"
body="Status:"

Econ=`egrep -e "ORA-" ${LOGFILE} | wc -l`
ECon1=`grep -li "File complete" ${LOGFILE} | wc -l`
echo "Econ is $Econ and ECon1 is $ECon1"

if test `egrep -e "ORA-" ${LOGFILE} | wc -l` -gt 0 ||
test `grep -li "File complete" ${LOGFILE} | wc -l` -eq 0
echo "IF SEND EMAIL"
then
echo "ELSE SEND EMAIL"
SendEmail I "${subject}" "Logfile failed" "emailaddress"
else
SendEmail I "${subject}" "Logfile Processed" "emailaddress"

echo
timeecho "NOTIFICATION SEND"
echo

I see my logfile does not have ORA messages and File completed is there. Still I get email Logfile failed in my email. Why??


Following is the output of script

+ subject=Logfile Status
+ body=Log file /opt/oracle/job_072507.log follows:
+
+ + wc -l
+ egrep -e ORA- /opt/oracle/job_072507.log
Econ= 0
+ + wc -l
+ grep -li File complete /opt/oracle/job_072507.log
ECon1= 1
+ echo Econ is 0 and ECon1 is 1
Econ is 0 and ECon1 is 1
+ wc -l
+ egrep -e ORA- /opt/oracle/job_072507.log
+ test 0 -gt 0
+ wc -l
+ grep -li File complete /opt/oracle/job_072507.log
+ test 1 -eq 0

+ SendEmail I "Logfile Status" "Logfile failed" "emailaddress"

+ timeecho NOTIFICATION SEND
04:06:06: NOTIFICATION SEND
+ echo

Re: Need help with if statement [message #254086 is a reply to message #254076] Wed, 25 July 2007 13:19 Go to previous message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
use it as sample.
http://www.scribd.com/doc/201416/This-Script-search-for-Oracle-error-messages
Previous Topic: ORA-29907: specified operator does not exist
Next Topic: bash script <newbe>
Goto Forum:
  


Current Time: Fri Nov 22 04:13:57 CST 2024