You've gotten many good suggestions, but the main problem is that you
are doing a TCP ping, and I'm pretty sure you are expecting the results
to match your ICMP ping.

>From the Perldoc:
"You may choose one of six different protocols to use for the ping. The
"tcp" protocol is the default. Note that a live remote host may still
fail to be pingable by one or more of these protocols. For example,
www.microsoft.com is generally alive but not "icmp" pingable."


You should change this line

   my $p = Net::Ping->new();

to

   my $p = Net::Ping->new("icmp");


and that will make your results match your "manual" ping results.


   


-----Original Message-----
From: Mazhar [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 29, 2006 8:44 AM
To: Perl Beginners
Subject: Script Required to Check a range of IP's

<snip>

I have written down the below and needs your help because it is not
giving
me the correct ouptut.

<snip>

my $p = Net::Ping->new();
foreach my $host (@host_array)
    {
        print "$host is ";
        print "NOT " unless $p->ping($host, 2);
        print "reachable.\n";
        sleep(1);
    }
$p->close();

<snip>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to