I'm using V 2.02 of Net::Ping, but for some reason nothing will work. I understand that 'icmp' pings require UID 0 (root) (someone told me that Net::Ping sends raw packets, hence the need for root). But, I can't get TCP or UDP pings to work either.

I thought it might be some kind of permissions issue, but the test script runs with my UID (i've watched it in the process list), and i've been able to ping the boxes (both with backticks and from ping in the shell - same thing, i know - so it's not a question of permissions.

or is it? here's the code (straight outta the documentation):

use Net::Ping; my @host_array = qw( www.slashdot.org www.deja.com www.perlmonks.org +); my $proto = 'tcp'; my $def_timeout = '40'; my $bytes = '52'; my $p = Net::Ping->new($proto, $def_timeout , $bytes); foreach my $host (@host_array) { print "$host is "; print "NOT " unless $p->ping($host, 2); print "reachable.\n"; } $p->close();
and when i run it:
bclarkso-sun:/users/bclarkso/snips --> perl -w ping.pl www.slashdot.org is NOT reachable. www.deja.com is NOT reachable. www.perlmonks.org is NOT reachable.

In reply to Net::Ping not working by geektron

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.