in reply to Pingger
at the end of that.foreach my $host (@iparray) { if ( $p->ping( $host )){ print " $host is alive\n ";
#!/usr/bin/perl use warnings; use Net::Ping; use Socket; $ipnumber ="192.168.30"; chomp $ipnumber; @iparray = map $ipnumber. ".$_",1..254 ; chomp $ipnumber; #open (ERRORLOG, ">errorlog"); #open (OFFLINE,">offline"); #open (ONLINE,">online"); my $proto = 'icmp'; my $def_timeout = '5'; my $bytes = '64'; my $p = Net::Ping->new($proto, $def_timeout , $bytes); foreach my $host (@iparray) { if ( $p->ping( $host )){ print " $host is alive\n "; } #foreach my $host (@iparray) { # $testing = $p $host; # print "$testing"; # print "$host offline " unless $p->ping($host,1); # print "$host online " unless $p->ping($host,0); # print ERRORLOG "$host offline " unless $p->ping($host,1); # print OFFLINE "$host"unless $p->ping($host,1); # print ONLINE "$host online" unless $p->ping($host,0); } $p->close();
|
|---|