in reply to Net::Ping Problems

If a sysadmin decides, somewhere down the track, that tcp echo ports should be turned off for security reasons, your script will fail. In that event, you will have to switch to ICMP, and such a script can only be run as root. Note that this is what you do when you "ping from the command line". If you look closely at the ping binary, you will see that it is suid root.

There is nothing wrong with patching the Net::Ping source code per se to achieve your ends, but now it's something to remember when you upgrade Perl (read: something you are going to forget :). In other words "one more damned thing to go wrong."

A better solution would be to eval the Net::Ping call, that way, if and when it fails, you'll trap the error and be able to continue your script. (The croak message will be delivered to the $@ variable -- you might want to (sys)?log it somewhere).

You might also want to investigate Parallel::ForkManager, which, as its names suggests, will let you run a farm of pingers. This will stop single timeouts from dragging your program's run-time into the ground.

Replies are listed 'Best First'.
Re: Re: Net::Ping Problems
by Paulster2 (Priest) on Oct 22, 2003 at 22:17 UTC

    Thanks for the suggestions, I will check into Parallel::ForkManager tomorrow when I get into work!
    Paul