in reply to Using Net::Ping for broadcast address
If you can parse /etc/hosts it might pay to put a distinguishing comment on the lines that are servers (### SERVER ###). You could then parse the file for these entries and build a list of known servers to ping via their direct address. Don't know it this is exactly what you are looking to accomplish, but you might want to try that approach instead. Might take some work to fix up your /etc/hosts file, but it would be a one-timer.#! /usr/local/bin/perl -w use strict; use Net::Ping; my $IPBlk; my $FirstOctets = "10.0"; my @ValidOctets = (1, 5, 7); foreach my $ThirdOctet (@ValidOctets) { my $sbnt = "$FirstOctets." . "$ThirdOctet" . ".0"; print "Pinging: $sbnt\n"; my $p = Net::Ping->new(); if ($p->ping("$sbnt") ) { print "host exists\n"; } else { print "Host does not exist\n"; } print "$?\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using Net::Ping for broadcast address
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 |