[70]Check your services file for a listing of port numbers and their corresponding services. On Unix systems, this file is usually in the directory /etc; on Windows it is usually in a directory such as C:\WINNT \System32\drivers\etc, though its location may vary depending on the version of Windows you are using.
$ telnet mail.ora.com 25 220 smtp.oreilly.com ESMTP O'Reilly & Associates Sendmail 8.11.2 ready HELO mydomain.com 250 OK QUIT 221 closing connection
HELO mydomain.com QUIT
$ /opt/OV/local/bin/netcat/nc -i 1 mailserver 25 < input.txt
$ /opt/OV/local/bin/netcat/nc -i 1 mailserver 25 < input.txt > mail_good
#!/usr/local/bin/perl # filename: mail_poller.pl $HOME_LOC = "/opt/OV/local/bin/netcat"; $NC_LOC = "/opt/netcat/nc"; $DIFF_LOC = "/bin/diff"; $ECHO_LOC = "/bin/echo"; $MAIL_SERVER = "mail.exampledomain.com"; $MAIL_PORT = 25; $INPUT_FILE = "$HOME_LOC\/input.txt"; $GOOD_FILE = "$HOME_LOC\/mail_good"; $CURRENT_FILE = "$HOME_LOC\/mail_current"; $EXIT_FILE = "$HOME_LOC\/mail_status"; $DEBUG = 0; print "$NC_LOC -i 1 -w 3 $MAIL_SERVER $MAIL_PORT \< $INPUT_FILE \> $CURRENT_FILE\n" unless (!($DEBUG)); $NETCAT_RES = system "$NC_LOC -i 1 -w 3 $MAIL_SERVER $MAIL_PORT \< $INPUT_FILE \> $CURRENT_FILE"; $NETCAT_RES = $NETCAT_RES / 256; if ($NETCAT_RES) { # We had a problem with netcat... maybe a timeout? system "$ECHO_LOC $NETCAT_RES > $EXIT_FILE"; &cleanup; } $DIFF_RES = system "$DIFF_LOC $GOOD_FILE $CURRENT_FILE"; $DIFF_RES = $DIFF_RES / 256; if ($DIFF_RES) { # looks like things are different! system "$ECHO_LOC $DIFF_RES > $EXIT_FILE"; &cleanup; } else { # All systems go! system "$ECHO_LOC 0 > $EXIT_FILE"; &cleanup; } sub cleanup { unlink "$CURRENT_FILE"; exit 0; }
# Check the mail server and create a file that we can poll via OpenView 1,11,21,31,41,51 * * * * /opt/OV/local/bin/netcat/mail_poller.pl
serviceInfo OBJECT IDENTIFIER ::= { mauro 5 } -- BEGIN - serviceInfo -- serMailPort OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS mandatory DESCRIPTION "This file is updated via crontab. It uses netcat to check the port and push a value into this file. FILE-NAME: /opt/OV/local/bin/netcat/mail_status" ::= { serviceInfo 0 }
Copyright © 2002 O'Reilly & Associates. All rights reserved.