Click to See Complete Forum and Search --> : Help with perl script


sgt_b
11-06-2002, 05:51 PM
I have a script that was given to me that queries a nameserver for zones connected with IP addresses. As of right now it uses a variable to scan the last octet of an IP address (1-255). I'd like to be able to do the last 2 octets. I'm sure the script would explain things better than I could.
For the record I have no idea how to write or even modify perl scripts, so any help would be greatly appreciated.

Here's the script:
-----------------------------------
#!/usr/bin/perl
#
use strict;
my $i;
my $out;
my $subnet = "64.4.13";

for ($i = 1; $i < 255; $i++) {
$out = `dig -x $subnet.$i +short`;
if (length($out) < 3) {
print "Addr Not found\n";
}
else {
print $out;
}
}
-----------------------------------

Again, thak you for any help, as this script would be a great help to me!

bwkaz
11-06-2002, 06:58 PM
Well, I don't know Perl hardly at all, but this looks promising:

#!/usr/bin/perl
#
use strict;
my $i;
my $j;
my $out;
my $subnet = "64.4";

for ($i = 0; $i <= 255; $i++) {
for ($j = 1 ; $j < 255; $j++) {
$out = `dig -x $subnet.$i.$j +short`;
if (length($out) < 3) {
print "Addr Not found\n";
}
else {
print $out;
}
}
} That should work, anyway. I'd test it if I had dig installed, but I don't. Assuming the original does what it's supposed to, though, this should work as well.

sgt_b
11-07-2002, 10:52 AM
Great thanks for all the help! I just tried this out, and the output is a little funny, but this has gotten me on the right track. I should be able to get it from here.

Thanks again!
:)