Perl使用Net::Ping

前端之家收集整理的这篇文章主要介绍了Perl使用Net::Ping前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
use warnings;
use Net::Ping;
if ($#ARGV <0){
   print "请输入一个参数\n";
  exit(-1);
}
$var=$ARGV[0];
@ARRAY="";
for ($i = 1;$i<=255;$i++){
push  @ARRAY,"$var.$i"};
foreach $host (@ARRAY){
$p = Net::Ping->new("icmp");
# print "$host is alive.\n" if $p->ping($host,5);
print "$host is ";
print "lost " unless $p->ping($host,2);
print "reachable.\n";
$p->close();
#sleep(1);
}

猜你在找的Perl相关文章