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



On 6/29/06, Ryan Frantz <ryanfrantz@xxxxxxxxxxxxxxxx> wrote:



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

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>



I am giving you all the sample input file...

11.1.1.1
111.1.1.1
1.111.1.1
1.1.2.3

All the above IP's are in a new line..

Relevant Pages

  • Re: Round off
    ... multiply the number by 100, then round it, then divide that by 100. ... Some folks rather hassle a person over a well-meant question - ... difference between rounding to a multiple of 0.01 giving a Number, ... TP/BP/Delphi/jscr/&c, FAQ items, links. ...
    (comp.lang.javascript)
  • Re: Rocket fuel
    ... but none other than Roger the Rocket Clemens has been implicated ... Performance Enhancing Drugs. ... I like the multiple, "I never tested positive" statements is the articles. ... Damn those folks in Salem had ...
    (rec.bicycles.racing)
  • Re: Thank You for Listening
    ... any way to buy multiple copies ... but ship directly to multiple other folks? ... personally accommodate requests like direct shipment to multiple ... If problems continue with CD BABY please contact me directly. ...
    (rec.music.makers.guitar.acoustic)
  • Re: Locations around the world of MS people
    ... It's too bad Google Maps are not accesible to Webtv folks. ... a crowded area how about a cirlcle with an actual number in it? ... members on the members site, but showing multiple X's rather than single ...
    (alt.support.mult-sclerosis)
  • Re: Straw poll...
    ... you folks place? ... When you look as though you are backing a 3 or 4 races, do you place single bets or multiple bets? ...
    (uk.sport.horseracing)