Re: Script Required to Check a range of IP's
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 29 Jun 2006 10:22:36 -0700
Mazhar wrote:
Hi Folks,
I have a requirement of writing down a script to check the range of IP's in
a text file and display them which all are active and not active.
I have written down the below and needs your help because it is not giving
me the correct ouptut.
################################################################
#!/usr/bin/perl
use strict;
use warnings;
use Net::Ping;
my $file_name=$ARGV[0];
my $line;
my @host_array;
open(FILE,"$file_name") || die "Not been Accessed";
while (<FILE>) {
chomp;
@host_array=$_;
}
I think your script is fine except for this line. you want to use push
to add the ip to your array. the way you're doing it your array gets
overwritten each time.
push @host_array, $_;
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();
-jp
.
- References:
- Script Required to Check a range of IP's
- From: Mazhar
- Script Required to Check a range of IP's
- Prev by Date: Re: Script Required to Check a range of IP's
- Next by Date: regexp pattern matching
- Previous by thread: Re: Script Required to Check a range of IP's
- Next by thread: RE: Script Required to Check a range of IP's
- Index(es):
Relevant Pages
|