Script with or and "And" not working

I have this portion of the script but is not working.  It is supposed to send an email because the log has a message that is not within this message that can be ignored:

•      EXP-00007: dictionary shows no columns for AAIS.TMP*
•      EXP-00007: dictionary shows no columns for AAIS.LIJPKGS_NOFAC
•      EXP-00007: dictionary shows no columns for AAIS.EDTTNLIJPKGS
•      EXP-00007: dictionary shows no columns for AAIS.DUP_PKGMEQ_TN1

The email must be sent if found one of this messages:

ORA-|rejected|Killed|Server out
EXP-00007 for other tables that are not one of the above

if [[ $(egrep -i -c "ORA-|rejected|Killed|Server out" "$log" -gt 0) || $(egrep -i -c "EXP-00007: dictionary shows no columns for" "$log" -eq 0) && $(egrep -i -c "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1" "$log" -eq 0) ]]; then mailx -s "Full Structure export of Aais production with error $log" mail@mail.com
LVL 8
LindaCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

neteducationCommented:
found=0
if egrep (ORA-|rejected|Killed|Server out) $log >/dev/null
then
found=1
fi
if grep EXP-00007 $log >/dev/null
then
found=1
if egrep (AAIS.TMP||AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1) $log >/dev/null
then
found=0
fi
fi
if (( found==1 ))
then
mailx -s "Full Structure export of Aais production with error $log" mail@mail.com
fi
0
LindaCAuthor Commented:
Thank you for the update, checking this script.
0
LindaCAuthor Commented:
It did not send the email.
I run it like this:  nohup ksh test.sh

:/export/home/oracle/dba/scripts> ksh test.sh
test.sh[7]: syntax error at line 7 : `(' unexpected
test.txt
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

LindaCAuthor Commented:
Rp
0
lanboyoCommented:
The above is slightly off what you need, if there is a line with a different EXP-00007 and one with the AAIS.TMP... int eh same file it will not send the mail because there is a AAIS.TMP... even though there is also one without AAIS.TMP...


SO searching for EXP-00007 and piping it into a egrep -iv -c will evaluate each line in the log file, which is what you want.

=== Revised Script ===


log=$1
PARAM1=$(egrep -i -c "ORA-|rejected|Killed|Server out" "$log")
PARAM2=$(egrep -i -c "EXP-00007: dictionary shows no columns for" "$log")
PARAM3=$(egrep -i -c "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1" "$log")
PARAM4=$(egrep -i  "EXP-00007: dictionary shows no columns for" "$log" | egrep -iv -c "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1")
#
if [[ $PARAM1  -gt 0  || $PARAM4 -gt 0 ]] ; then
echo  "Full Structure export of Aais production with error $log" mail@mail.com
echo  matches in log file $log PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3 $PARAM4=$PARAM4
else
echo  no matches in log file $log PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3 PARAM4=$PARAM4
fi


=== Results ===

mybox ~
$ cat gus1
.      EXP-00007: dictionary shows no columns for AAIS.TMP*
.      EXP-00007: dictionary shows no columns for AAIS.LIJPKGS_NOFAC
.      EXP-00007: dictionary shows no columns for AAIS.EDTTNLIJPKGS
.      EXP-00007: dictionary shows no columns for AAIS.DUP_PKGMEQ_TN1

mybox ~
$ cat gus2
.      EXP-00007: dictionary shows no columns for AAIS.TMP*
.      EXP-00007: dictionary shows no columns for AAIS.LIJPKGS_NOFAC
.      EXP-00007: dictionary shows no columns for AAIS.EDTTNLIJPKGS
.      EXP-00007: dictionary shows no columns for AAIS.DUP_PKGMEQ_TN1
.      EXP-00007: dictionary shows no columns for ICARE.ABOUT.THIS.LINE

mybox ~
$ ./testy.sh gus1
no matches in log file gus1 PARAM1=0 PARAM2=4 PARAM3=4 PARAM4=0

mybox ~
$ ./testy.sh gus2
Full Structure export of Aais production with error gus2 mail@mail.com
matches in log file gus2 PARAM1=0 PARAM2=5 PARAM3=4 PARAM4=1

mybox ~
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LindaCAuthor Commented:
Checking this script.
0
LindaCAuthor Commented:
Aha!   that worked and I tried with several options modifiying the script.
Thank you very much!

I added the sending of the log in the line beginning with "cat" .  So this is the resulting script:
(To all those reading this posting remember that you have to paste it in notepad and you have to make sure that one line , like the one that begins with PATH it has to be "one line" in notepad not 4 lines.)

#!/bin/ksh
PATH=/usr/bin::/home/app/oracle/product/9.2.0/lib:/usr/bin:/usr/ccs/bin:/usr/ucb
:/etc:/usr/local/bin:/home/app/oracle/product/9.2.0/bin:/usr/sbin:/usr/bin:/usr/
openwin/bin:/home/app/oracle/product/9.2.0/network/agent/events/oracle/host/spac
e:/home/app/oracle/product/9.2.0/OPatch:/bin
export PATH
cd /export/home/oracle/dba/logs
log=exportaais.2010-03-24.log
PARAM1=$(egrep -i -c "ORA-|rejected|Killed|Server out" "$log")
PARAM2=$(egrep -i -c "EXP-00007: dictionary shows no columns for" "$log")
PARAM3=$(egrep -i -c "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1" "$log")
PARAM4=$(egrep -i  "EXP-00007: dictionary shows no columns for" "$log" | egrep -iv -c "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1")
#
if [[ $PARAM1  -gt 0  || $PARAM4 -gt 0 ]] ; then
cat $log|mailx -s "Full Structure export of Aais production  with error $log" mail@mail.com
echo  matches in log file $log PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3 $PAR
AM4=$PARAM4
else
echo  no matches in log file $log PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3 PARAM4=$PARAM4
fi
0
LindaCAuthor Commented:
Thank you for sharing your knowledge !
0
lanboyoCommented:
To make the mail message a little more informative you could pipe the cat thru the greps. This is from a blackberry so the carraige returns will be attrocious...

egrep -i "ORA-|rejected|Killed|Server out|EXP-00007: dictionary shows no columns for" "$log" | egrep -iv  "AAIS.TMP|AAIS.LIJPKGS_NOFAC|AAIS.EDTTNLIJPKGS|DUP_PKGMEQ_TN1" | mail command
0
LindaCAuthor Commented:
Oh thank you!
0
LindaCAuthor Commented:
I tested and it worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.