I am having problems with this. For some reason the script connects even
though nothing is listening on that port.

ie. If I shut down the smtp server I can no longer 'telnet hostname 25'
so the script should die, but it doesn't.

Here is what I have:

#!/usr/local/bin/perl -w

use IO::Socket::INET;

$remote_host    = "85.3.25.115";
$remote_port    = 25;

my $sock = IO::Socket::INET->new(PeerAdd   => $remote_host,
                                 PeerPort  => $remote_port,
                                 Proto     => "tcp",
                                 Type      => SOCK_STREAM,   # added
this for testing, this has no effect either way
                                 Timeout   => 10)
        or die "Could not connect to $remote_host:$remote_port : $@\n";

print $sock "HELO\n";
$reply = <$sock>;
print "$reply\n";


Nothing is ever printed as well, however I am mainly interested in the
script dying where it is supposed to. 

Any ideas?


Thanks,
CC

---
Chuck Carson
Clinicomp International
Sr. Systems Engineer
San Diego, California
O: +1 (858) 646-2095
F: +1 (858) 297-8570



-----Original Message-----
From: James Kelty [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, August 28, 2001 10:14 AM
To: perl-cgi
Subject: RE: Perl script to monitor sendmail


#!/usr/bin/perl -w
use IO::Socket::INET;
my $sock = IO::Socket::INET->new(PeerAdd   => "hostname",
                                 PeerPort  => "smtp(25)",
                                 Proto     => "tcp",
                                 Timeout   => "Something Reasonable like
5
or 10");
print "System down" unless $sock;


-James


-----Original Message-----
From: perl-cgi [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 28, 2001 9:41 AM
To: [EMAIL PROTECTED]
Subject: Perl script to monitor sendmail



We are using a Windows based SMTP virus scanner that scans port 25 and
then forwards to are real mail server which is SuSE based. This damn
software product keeps crashing and there is no way to know when it
crashes unless you login with PC Anywhere and do the GUI thing. Can
anyone share some sample code that would allow a perl script hosted on a
Unix machine periodically connect to the mail port and determine if it
is up or not.

Thanks,
CC



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to