in reply to is there script to detect if remote machine is alive/reachable w/o using Net::Ping?
Did you specify a timeout period for ping? You can use -t to tell ping when you want it to exit. Here's some code that returns true if the remote machine pings at least once in 7 seconds:
sub ping { my $ip = shift; my $p = `/sbin/ping -c 5 -t 7 $ip | /usr/bin/grep 'packet loss'`; unless ( $p =~ /(\d+)% packet loss/ ) { die ( "Bad Response:\n$p\n" ); } my $loss = $1; print "Loss = $1 "; return ( $loss != 100 ); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: is there script to detect if remote machine is alive/reachable w/o using Net::Ping?
by perigeeV (Hermit) on Jun 07, 2002 at 00:41 UTC | |
by Anonymous Monk on Jun 07, 2002 at 05:27 UTC |