Two parameters in a unix script param1 or not param2 then send email

I have the following lines in a script that is evaluating wrong.
I want to evaluate if PARAM1 or not PARAM2 then (do the then)  else (do the else)
The log does not have any of the PARAM1 but it has the PARAM2 and is  going to the "then'.


PARAM1=$(egrep -i -c "ORA-|rejected|Killed|skipped" "$log")
PARAM2=$(egrep -i -c "Server status = 0" "$log")
if [[ $PARAM1  -eq 0 || $PARAM2  -eq 0 ]]; then
    (cat $TXTERROR;uuencode $ATTFILE Coldbackup-log.txt) | mail -s "$SUBJECT" $M
AILTO
else
    (cat $TXTDEPLOY;uuencode $ATTFILE Coldbackup-log.txt) | mail -s "$SUBJECT" $
MAILTO
fi
LVL 8
LindaCAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

woolmilkporcCommented:
>> I want to evaluate if PARAM1 or not PARAM2 <<

shouldn't it be

if [[ $PARAM1  -eq 0 || $PARAM2  -ne 0 ]]; then ...

?

wmp
0
LindaCAuthor Commented:
Checking.
0
LindaCAuthor Commented:
I don't know why it email me with error:

PARAM1=$(egrep -i -c "ORA-|rejected|Killed|skipped" "$log")
PARAM2=$(egrep -i -c "Server status = 0" "$log")
if [[ $PARAM1  -eq 0 || $PARAM2  -ne 0 ]]; then
    (cat $TXTERROR;uuencode $ATTFILE Coldbackup-log.txt) | mail -s "$SUBJECT" $M
AILTO
else
    (cat $TXTDEPLOY;uuencode $ATTFILE Coldbackup-log.txt) | mail -s "$SUBJECT" $
MAILTO
fi
text-deploy.txt
text-error.txt
prueba.txt
Coldbackup-log.txt
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

woolmilkporcCommented:
It will email you with error (the "then" branch)
 if the log does not contain ( ORA- or rejected or Killed or skipped) [because the count returned by grep is zero)
  or if the log does contain ( Server status = 0 ) [because the count returned by grep is zero]

So I think you should invert your logic ...

wmp
0
woolmilkporcCommented:
I mean - exchange -eq and -ne, because it seems that it should work just contrary to what you posted.
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
sjm_eeCommented:
$ cat doit
#!/bin/sh

PARAM1=$1
PARAM2=$2
if [[ $PARAM1  -eq 0 || $PARAM2  -eq 0 ]]
then
    echo "then"
else
    echo "else"
fi
$ ./doit 0 0
then
$ ./doit 1 0
then
$ ./doit 0 1
then
$ ./doit 1 1
else

Problem?
0
LindaCAuthor Commented:
Checking
0
dougaugCommented:
You can do this:

egrep -i -c "ORA-|rejected|Killed|skipped" "$log"
PARAM1=$?                                      
egrep -i -q  "Server status = 0" $log
PARAM2=$?                                      
if [[ $PARAM1  -eq 0 || $PARAM2  -ne 0 ]]; then
....

In this way you will get an error mail if any of the words ORA-|rejected|Killed|skipped appear on the log or if the phrase "Server status = 0" doesn't appear.

You will only get a deploy mail if none of the words ORA-|rejected|Killed|skipped exist and only if the string  "Server status = 0" exists in the log.
0
LindaCAuthor Commented:
egrep -i -c "Server status = 0" TBSPROD_COLD.2010-04-15.log  1
egrep -i -c "ORA-|rejected|Killed|skipped" TBSPROD_COLD.2010-04-15.log  0

So if [[ $PARAM1  -gt 0 || $PARAM2  -ne 1 ]]; then

because -c I think it means count ?
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.