Hi Guys,

I have an active wireless connection on my Linux box (Kubuntu 13.10). When I manually ping Google with ping www.google.com at the command prompt I get the following output:

PING www.google.com (173.194.34.144) 56(84) bytes of data. 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=1 t +tl=57 time=159 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=2 t +tl=57 time=190 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=3 t +tl=57 time=72.6 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=4 t +tl=57 time=199 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=5 t +tl=57 time=69.4 ms

But when I use Net::Ping in a perl script like this:

my $p = Net::Ping->new("tcp", 2); # With or without this next line. $p->port_number(getservbyname("http", "tcp")); if ($p->ping("www.google.com")) { print "Host is reachable\n"; return 1; } else { print "Host is not reachable\n"; return 0; }

I get "Host is not reachable" rather than the "Host is reachable" suggested by running ping manually.

What is happening here?

Thanks very much.

Steve.


In reply to Issues with network connectivity and Net::Ping by Steve_BZ

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.