Synping.pl

From Federal Burro of Information
Jump to navigationJump to search
#!/usr/bin/perl

use strict;

use Net::Ping;

my $prot = 'tcp';
my $port = 'smtp';

my $p = Net::Ping->new("syn");
$p->{port_num} = getservbyname($port, $prot);

foreach my $host (@ARGV) {
	$p->ping($host);
	print "PING: $host on $prot/$port\n";
}
while (my($host,$rtt,$ip) = $p->ack) {
	print "HOST: $host [$ip] ACKed in $rtt seconds.\n";
}