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.


In reply to Re: Net::Ping Problems by grinder
in thread Net::Ping Problems by Paulster2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.