[Techtalk] bash script
Sean McAfee
mcafee at transmeta.com
Tue Sep 18 00:19:18 EST 2001
"Philip J. Priest" <phil at blkbox.com> wrote:
>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.
>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
Every telnet implementation I'm familiar with insists on taking its input
from the terminal; you can't program it using stdin like this. I'm
surprised that it works on HP-UX.
I came up with a Perl solution that I think is pretty spiffy. A
functionally identical variant could doubtless be cooked up using your
language of choice.
perl -MIO::Socket <<EOPERL
\$sock = new IO::Socket::INET('205.219.16.88:25')
or die "Couldn't connect: \$!\n";
print \$sock <DATA>;
__DATA__
Helo
Mail From: int-dns1 at itsinc.com
Rcpt To: ppriest at itsinc.com
data
Subject: netcheck
Date check: $DAY
Network check:itsux17$STATE
More information about the Techtalk
mailing list