Synping.pl: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
(Created page with "<pre> #!/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...")
 
(No difference)

Latest revision as of 22:34, 6 March 2021

#!/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";
}