zuinc has asked for the wisdom of the Perl Monks concerning the following question:
This keeps returning 'ERROR' and doesnt print anything to 'pingallip.list'. Any ideas? Thanks.# Create a list of all possible IP addresses within subnet open(ALLIP, ">allip.list") || die "Unable to create file: allip.list\n +"; for ($i=0; $i<=20; $i++) { print ALLIP "$ip_subnet.$i\n"; } open(ALLIP, "allip.list") || die "Unable to open file: allip.list\n"; open(PINGALLIP, ">pingallip.list") || die "Unable to open file: pingal +lip.list"; while (<ALLIP>) { system("ping $_ >pingallip.list") && "Unable to create file: p +ingallip.l ist"; chomp; } open(OUTPUT, ">output.list"); open(PINGALLIP, "pingallip.list") || die "Unable to open file: pingall +ip.list"; my $line = 0; while (<PINGALLIP>) { chomp; #my $line = 0; #while (<ALLIP>) { #chomp; if ($_ eq~ m/is alive/) { $line++; last; } } close(ALLIP); if ($line) { print OUTPUT "$_\n"; } else { print "ERROR\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: system( ), printing output & matching
by ozone (Friar) on Apr 05, 2002 at 19:42 UTC | |
by zuinc (Novice) on Apr 05, 2002 at 20:16 UTC | |
by I0 (Priest) on Apr 06, 2002 at 02:22 UTC | |
|
Re: system( ), printing output & matching
by grinder (Bishop) on Apr 05, 2002 at 20:27 UTC | |
|
Re: system( ), printing output & matching
by earthboundmisfit (Chaplain) on Apr 05, 2002 at 19:35 UTC | |
|
Re: system( ), printing output & matching
by talexb (Chancellor) on Apr 05, 2002 at 19:39 UTC |