1.20091028
#!/usr/bin/perl -w
use Socket;
use Net::Ping;
open(FILE,"ip.txt")||die"can not open the file: $!";
@filelist=;
foreach $eachline (@filelist) {
chomp $eachline;
$p = Net::Ping->new('icmp');
for ($eachline)
{
print $eachline, " NOT reachable.\n" unless $p->ping($eachline, 2);
}
$p->close();
}
close FILE;
2.20091027
#!/usr/bin/perl -w
use Socket;
use Net::Ping;
$p = Net::Ping->new('icmp');
while(<>)
{
chomp;
(undef, undef, undef, undef, @addrs) = gethostbyname($_);
for (@addrs)
{
$ip = inet_ntoa($_);
print $ip, " NOT reachable.\n" unless $p->ping($ip, 2);
}
}
$p->close();
ping.pl < ip.txt
阅读(1495) | 评论(0) | 转发(0) |