I could swear on my life that i tried putting in "icmp" and it didn't make a difference, however I tried you snippet and it worked perfectly!!!! Thank you so much.


I have also come up with an alternative way of doing this without using Net::Ping, although I have heard that it is better to use Net::Ping for various reasons. for those who are interested, see my code below.


your code
#!/usr/bin/perl -w use strict; use Net::Ping; my $host = "127.0.0.1"; my $ping=Net::Ping->new("icmp"); if ($ping->ping($host,2)){ print "$host is alive"; }else{ print "$host unreachable" }

My alternative code (very sloppy but it did the trick)
#!/usr/bin/perl -w use strict; checkup(); sub checkup { my $host = "209.94.100.100"; my $packloss = `ping -c 1 -s 1 $host | grep loss | awk '{print \$7}'`; $packloss = substr($packloss,0,length($packloss) -1); if ($packloss ne "100%") { print "$host is up with $packloss packet loss\n"; }else { print "$host is down with $packloss packet loss\n"; }

In reply to Re: Re: Re: Re: Net:Ping HELP! by Anonymous Monk
in thread Net:Ping HELP! by dannc

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.