>
> Wonder if someone could help me, I am trying to write
> a script to pulls out all the machine names from a
> revese DNS file, some how, my script will only print
> out the machine names with 1.x.x.in-addr.arpa....
>
> $nslookup = '/usr/local/bin/nslookup';
> $dig = '/usr/local/bin/dig';
>
> @ZONES = qw/
> 1.x.x.in-addr.arpa
> 2.x.x.in-addr.arpa
> 3.x.x.in-addr.arpa
> 4.x.x.in-addr.arpa
> /;
>
> foreach $zone (@ZONES)
> {
> open (SOA, "$nslookup -timeout=3 -retry=1 -type=SOA
> $zone |") or die "Couldn't r
> un $nslookup -timeout=3 -retry=1 -type=SOA $zone";
>
> SOA: while (<SOA>)
> {
> chomp;
You don't need to chomp it, or you don't need $/ at
last of the next line.
> if (/^\S+.in-addr.arpa\s+nameserver = (\S+)$/)
You have to escape the . (ie: \.)
> {
> $soa=$1;
> if (open(DIG, "$dig AXFR $zone \@$soa |"))
> {
> while (<DIG>)
> {
> chomp;
> if (
> /\d+\s+1D\s+IN\s+\PTR\s+.+.this.is.my.domain./)
escape the dots again.
> {
> ($host) = $_ =~
> /\d+\s+1D\s+IN\s+\PTR\s+(.+).this.is.my.domain./;
Are you trying to say :
$host = $1 if (/\d+\s+1D\s+IN\s+\PTR\s+(.+)\.this\.is\.my\.domain./);
$sth = $_ =~ m//;
$sth will only be 1 if matched, or 'null' otherwise,
> push (@all_hosts, $host);
> }
> }
> close (DIG);
> last SOA;
So if DIG is successed one, the SOA while loop will be quit, is that
what you want? I don't know.
> }
> }
> }
> close(SOA);
> }
>
>
> What have I done wrong??
>
Not sure... coz I am not on a Linux box though =)
Perhaps the files have some problems too...
but 2 suggestions :
1. use strict and my.
2. Avoid to use Lable name same as Filehandle,
get confuse easy.
Rgds,
Connie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]