birdbrane has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to right a series of scripts to map out all of our *nix hosts on our intranet, in order to ease administration. One part of that script requires that I ping each address. Problem is, if the subnet doesn't exist, I don't want to ping 255 addresses only to find nothing.
I wrote a perl script to ping the broadcast address (using Net::Ping) but it comes back that the address doesn't exist (even though a command line ping does).
Am I doing something incorrectly here, or does Net::Ping not work for pinging broadcast addresses? I have tried w/ and w/o ICMP, again, to no avail.
For information purposes, here is the script:
#! /usr/local/bin/perl -w use strict; use Net::Ping; my $IPBlk; my $FirstOctets = "10.0"; my $ThirdOctet; for ($ThirdOctet = 1; $ThirdOctet <= 25; $ThirdOctet++) { $IPBlk = "$FirstOctets." . "$ThirdOctet"; my $sbnt = "$IPBlk" . ".0"; my $p = Net::Ping->new(); if ($p->ping("$sbnt") ) { print "host exists\n"; } else { print "Host does not exist\n"; } print "$?\n"; }
Many thanks in advance,
Joe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Net::Ping for broadcast address
by THRAK (Monk) on Mar 30, 2001 at 22:37 UTC | |
by birdbrane (Chaplain) on Mar 30, 2001 at 22:48 UTC | |
by THRAK (Monk) on Mar 30, 2001 at 23:09 UTC | |
by ybiC (Prior) on Mar 30, 2001 at 23:22 UTC | |
|
Re: Using Net::Ping for broadcast address (nmap -sP a.b.c.d/mask)
by ybiC (Prior) on Mar 30, 2001 at 23:19 UTC | |
by birdbrane (Chaplain) on Mar 30, 2001 at 23:48 UTC | |
|
Re: Using Net::Ping for broadcast address
by knight (Friar) on Mar 31, 2001 at 04:09 UTC |