Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Compare zone files in directory with what is listed in named.conf

by Kenosis (Priest)
on May 15, 2013 at 22:17 UTC ( #1033743=note: print w/ replies, xml ) Need Help??


in reply to Compare zone files in directory with what is listed in named.conf

The following first captures the file names in named.conf and places them into a hash. It then globs the zonefiles' directory, and attempts to find each listed file from that directory in the hash. If the file name's not in the hash, it's pushed onto @unlistedFiles for later processing:

use strict; use warnings; my ( %named_conf, @unlistedFiles ); open my $fh, '<', 'named.conf' or die $!; /\s+file\s+"([^"]+)/ and $named_conf{$1}++ for <$fh>; close $fh; chdir 'zonefiles' or die $!; !defined $named_conf{$_} and push @unlistedFiles, $_ for <db.*>; print "$_\n" for @unlistedFiles;

Files in zonefiles directory:

db.127.0.0 db.brian.com db.cache db.test.com db.what db.why

Output using your named.conf:

db.what db.why

Hope this helps!


Comment on Re: Compare zone files in directory with what is listed in named.conf
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033743]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2015-07-05 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls