use strict;
use warnings;
use Net::Ping;
my $rede = '192.168.0';
my ($addX,$contHost) = (0,0);
while( $addX++ < 255 ){
my $p = Net::Ping->new();
if ($p->ping("$rede.$addX")){
print "$rede.$addX is alive.\n";
$contHost++;
}else{
print "$rede.$addX is dead.\n";
}
$p->close(); }
print "Total Host : $contHost\n";
result :
./pingHost.pl
192.168.0.1 is alive.
192.168.0.2 is alive.
192.168.0.3 is dead.
192.168.0.4 is dead.
...
0 comentários:
Post a Comment