[Techtalk] bash script
Philip J. Priest
phil at blkbox.com
Mon Sep 17 11:14:44 EST 2001
Ive got a script that pings and if machines are down send email alerts. And
part of it is working. But when it trys to send out the email i never get
the email.
this same script works on my hp-ux machine.
im running redhat 7.1
#!/bin/bash
set -vx
export DAY=`date +%I%M%m%d%Y`
export cntr=0
/bin/ping int-dns2 -c 6 -s 1 | tail -1 | awk '{print $7}' > pack
for C in `cat pack`
do
echo "${C%\%}"
done > pack1
export h=`cat pack1`
if [ $h != 0 ]
then STATE=down
export cntr=1
else STATE=up
export STATE
fi
if
[ $cntr -ne 0 ]
then
echo Helo > metro
echo Mail From: int-dns1 at itsinc.com >> metro
echo Rcpt To: ppriest at itsinc.com >> metro
echo data >> metro
echo Subject: netcheck >> metro
echo 'Date check: '$DAY'' >> metro
echo 'Network check:itsux17'$STATE'' >> metro
echo >> metro
echo . >> metro
echo quit >> metro
telnet 205.219.16.88 25 < metro
fi
exit
More information about the Techtalk
mailing list