Perl ping

<pre name="code" class="html">use Net::Ping;
 $p = Net::Ping->new("icmp");
 while (1==1){
 open (LIST,"<","list.txt") || die "$!\n";
 while (<LIST>)
 {chomp;
 my $host=$_;
 if ($p->ping($host))
 {print "$host is alive\n";}
 else
 {print "$host is die\n"};
 }
 close LIST;
 sleep(5);
   }
   
192.168.11.1
192.168.10.1
192.168.5.1



   

posted @ 2016-10-27 17:34  czcb  阅读(109)  评论(0编辑  收藏  举报