Ping Multiple Machines in Perl
Evening Gents!
Im having a little trouble with a perl script to ping multiple machines. I can ping one easily enough with use Net::Ping; my $ip = '724.125.237.50'; my $ping = Net::Ping->new( "icmp", 1, 64); if ( $ping->ping($ip) ) { print "$ip answered\n"; } else { print "$ip did not answer\n"; } But i cant seem to ping multiple machines, i've tried something like. use Net::Ping; my @ip = qw(74.125.237.48 74.125.237.51 123.123.123.123); my $ping = Net::Ping->new("icmp", 5); foreach $ip (@ip){ $ping->ping($ip); print "$ip answered\n"; sleep(1); } But obviously this isnt working! Any help would be great peeps Thanks |
i can ping them with your second script. I've changed 'icmp' to 'syn'
|
Try using different variable names...
I mean for ips list, use @ips and $ip for each ip |
All times are GMT -5. The time now is 04:13 AM. |