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



On 6/29/06, Mazhar <syedmazhar.hasan@xxxxxxxxx> 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=$_;
}

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();

close (FILE);

###########################################################

Needs your help on the above

Regards
Mazhar



If it helps, I wrote a script to ping a list of mirrors, from a list
of fqdn's...

http://perl-e.chovy.com/sample/ping-mirrors
http://perl-e.chovy.com/sample/ping-mirrors.txt


--
Anthony Ettinger
Resume: http://chovy.dyndns.org/resume.html
(I'm currently available for contract/telecommute work!)
.



Relevant Pages

  • Automate script to export display
    ... X server running locally so I can export DISPLAY locally to me and run ... What would be an efficient way to put a in a script those commands so ... 1.Identify the host that I have logged from ...
    (comp.os.linux.x)
  • Script Required to Check a range of IPs
    ... 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. ... print "$host is "; ...
    (perl.beginners)
  • Re: Script Required to Check a range of IPs
    ... 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. ... cat ips.txt | xargs nmap -sP ...
    (perl.beginners)
  • Re: PHP mail marked is phishing
    ... I am writing a simple script that sends an email to a user using ... or that maybe your host doesn't have a ... reverse DNS entry? ...
    (comp.lang.php)
  • Display selected lines from a .txt file
    ... I am writing a script that will allow the user to search for selected words in a .txt file. ... The result will display the entire line from the .txt file that contains the selected word. ...
    (comp.soft-sys.matlab)