Hey everyone. I'm writing a script that uses rsync with ssh to sync files with a bunch of boxes. I want it to check if the clients are up before attempting to rsync, so I used Net::Ping.

Trouble is, Net::Ping returns false even if the host is up. Here is a snippet of test code I used.
#!/usr/local/bin/perl -w use Net::Ping; $host = "138.238.227.90"; $p = Net::Ping->new(); print "$host is alive.\n" if $p->ping($host); $p->close();
When I run this, I get no return, no matter what the host state. And this is directly from the Net::Ping docs.
I'm on an Ultra10 running Solaris 7. Whats more is that when I tried to test it out on a Linux box (2.2.12-20smp) I get this:
Use of uninitialized value at /usr/lib/perl5/5.00503/i386-linux/Socket +.pm line 295. Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be +16 at /usr/lib/perl5/5.00503/i386-linux/Socket.pm line 295.

Perl version on Linux is 5.005_03
Perl version on Solaris is 5.005_03
Net::Ping version on both is 2.02

If anyone has any suggestions, including an alternative to Net::Ping, I would be most grateful.

In reply to Trouble with Net::Ping by sagat

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.