I have got a script which is not doing what it's
supposed to do.
In short, the script should grep the output of a
program, awk for one column & send an email to me if
anything from that column matches my criteria.
Code:
#!/bin/bash
BINARY="/usr/sbin/binary"
MAIL="/bin/mail"
RECPT="me@yahoo.co.uk"
SUB1="Number does match for `hostname`"
SUB2="Number doesn't match for `hostname`"
ERROR_VALUE="Please try again later"
# grep for specific column
PROG1="`$BINARY -l | grep -n 1 | awk {'print $7'}`"
# mail me to let me know that it is not working
PROG_ERR="`$BINARY -l | $MAIL -s "$SUB2" $RECPT`"
# mail me to let me know that it is working
PROG_OK="`$BINARY -l | $MAIL -s "$SUB1" $RECPT`"
# the total outout
PROG3="`$BINARY -l`"
# conditions
if [ "$PROG1" = "0.00" ] || [ "$PROG1" -gt "1000" ]
|| [ "$PROG" = "1000" ]; then
echo $PROG_ERR
elif [ "$PROG3" == "$ERROR_VALUE" ]; then
echo $PROG_ERR
else
echo $PROG_OK
fi
The program should scan all 3 or 4 lines in the column and grep for 0.00 or 1000 if there is any.
Any kind of help would be appreciated.