$p = Net:ing->new('icmp');
if($p->ping($host)){
print "$host is reachable.\n";
} else {
print "$host is not reachable.\n";
}
$p->close();
I found that if you specify the icmp protocol (that's the standard ping protocol anyway) it works fine. [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href=
"Specifying the "icmp" protocol requires that the program be run as root or that the program be setuid to root."
I didn't pick that up before because I was running in under ActivePerl at home on Win98...
Also from perldoc Net:ing is:
"The icmp protocol requires that the program be run as root or that it be setuid to root. The tcp and udp protocols do not require special privileges, but not all network devices implement the echo protocol for tcp or udp."
This just doesn't seem a reliable way to do things... Can't you run the command as root or call the unix ping command directly? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href=
[tt]
$host='164.73.100.5';
open(PING,"/etc/ping $host|" || die;
while(<PING>){
[tab]print;
}
[/tt]
This will run the ping command and feed the results into your Perl script throught the PING handle [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href=
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.