RE: Script Required to Check a range of IP's



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:syedmazhar.hasan@xxxxxxxxx]
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>

.



Relevant Pages

  • Re: connecting via broadband?
    ... > Ping statistics for 193.252.22.137: ... >> mail server and that it is responsive so you get a mail session ... >> host that responds to 'ping' does NOT mean the server program is ... >> actually running or responsive on that host. ...
    (microsoft.public.outlook.general)
  • Re: host availability
    ... >>>google.com, my default gateway, comcast's mail server etc. ... a host was "up or down". ... If you don't get an answer to a ping request, ... happened to reset the interface right then, remote system got trojaned ...
    (comp.security.firewalls)
  • RE: ICMP (Ping)
    ... I do like your reasoning that others do not generally have a business need ... to ping your hosts, however I still prefer to allow this service not simply ... how many hosts do not respond to ICMP echo. ... DHCP server should be able to assume that if the IP were in use a host would ...
    (Security-Basics)
  • RE: Determine if Virtual PC is running
    ... I've just checked my source code and my code for PING actually derives from ... when pinging a local pc by host name, ... that IP-address will probably respond. ... We can check for SystemName via WMI hostname check for additional security. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to resolve names
    ... So I can ping and try to ssh/telnet the 2 other machines from my PC via ... I cannot do it by using their host names although I get proper ... # entry should stop if the search in the previous entry turned ... # passwd: files nis ...
    (comp.os.linux.networking)