Hello everybody,
I want to ping a couple of Hosts and add some informations
like the answer-time of the packet and the ip-address.
The Module Docs of the Net::Ping Module looks like you
get the duration and the ip Address within the return_value
for $p->ping( $host, $timeout)
but using this gives me an empty value.
Any Ideas?
I wonder where did you get the Module Docs from. When I do perldoc Net::Ping on my Win2K with Active Perl 5.6.1 build 633, I got this:
$p->ping($host [, $timeout]);
Ping the remote host and wait for a response. $host can be either the hostname or the IP number of the remote host. The optional timeout must be greater than 0 seconds and defaults to whatever was specified when the ping object was created. If the hostname cannot be found or there is a problem with the IP number, undef is returned. Otherwise, 1 is returned if the host is reachable and 0 if it is not. For all practical purposes, undef and 0 and can be treated as the same case.
The return value is either 1 or 0. No duration or ip address is mentioned.
Jing Wee
Here's my Code,
thank you in advance ..
##################################
use strict;
use Net::Ping;
my $p = Net::Ping->new('icmp',2);
my @servers = qw( HOST1 HOST2 HOST3 );
print "Content-type: text/html\n\n";
foreach(@servers){
if ( ( my $ret, my $duration, my $ip) = $p->ping($_, 2) ) {
print "$_ answered. $duration $ip <br>\n";
}else{
print "$_ timed out.<br>\n";
}
}
##################################
Mit freundlichen Gr��en / With best regards
Sascha Teifke
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
