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





-----Original Message-----
From: Mazhar [mailto:syedmazhar.hasan@xxxxxxxxx]
Sent: Thursday, June 29, 2006 11:44 AM
To: Perl Beginners
Subject: Script Required to Check a range of IP's

Hi Folks,


Howdy,

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";

To be of more help, I'd suggest that you provide some example input. Is
there one address per line? Multiple addresses per line (delimited).


while (<FILE>) {
chomp;
@host_array=$_;
}


If we have some example input, then we can tell if the 'while' block is
kosher. If there are multiple IP addresses, then you'll want to 'push'
the addresses into @host_array.

ry

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
.



Relevant Pages

  • Re: PHP and MySQL issue
    ... following PHP code to work on my website. ... // if multiple choices are permitted, ... foreach { ... so display ...
    (alt.php)
  • Re: Cannot connect to Win. Auth site with IP address in URL
    ... Internet Explorer can not display the webpage is a generic error message. ... If it still says the same thing then there is no response from IIS. ... httperr.log file on IIS server to see if http.sys is dropping the request for some reason (e.g. bad host name) ...
    (microsoft.public.inetserver.iis.security)
  • Q: IP addresses for interfaces and SBS 2003 (and more)
    ... As well I'd like it to host the VPN connections, ... I'd like the server to host a few SQL instances as well (which is possible ... I'm wondering if I give it multiple ... anyone have any luck with a multiport modem solution fox fax and dial ...
    (microsoft.public.windows.server.sbs)
  • Re: What is the best way to define the Imported C function
    ... Ada's String is not C's ... Firstly Integer is not necessarily int, ... Host: out Unbounded_String; ... Display: out Display_ID; ...
    (comp.lang.ada)
  • RE: Problem with X server
    ... Try tunneling everything through ssh. ... This gets around the need to use the xhost and export display settings. ... Subject: Problem with X server ... On the local host, type: ...
    (RedHat)