Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by NetWallah (Abbot)
on May 15, 2013 at 20:06 UTC ( #1033733=note: print w/ replies, xml ) Need Help??


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

Untested, but this should meet your requirements:

#!/usr/bin/perl # Putting all of the zonefiles lised in named.conf into an array use strict; use warnings; my $srce = "named.conf.brian"; my %zonefilenames; open(my $FH, "<", $srce) or die "Failed to open file $srce ($!)"; while (<$FH>){ next unless my ($filename) = m/file\s*"([^"]+)/; next if $filename eq "db.cache"; $zonefilenames{ $filename } =""; } close($FH); print "Zone Files: ",join( ", ", keys %zonefilenames)," \n"; # Putting listing of all of the files in ~/zonefiles directory into a +n array # Assigning variable to directory my $directory = "~/zonefiles/"; opendir(my $D, "$directory") or die "Can't opendir $directory: $!\n"; while ( readdir($D)){ next if m/^\./; # Ignore things with leading dots chomp; my $found = exists $zonefilenames{ $_ } ? "" : "Not found in zone +definition"; print "$_ : $found\n"; } closedir($D);
Update : Enabled "strict" and fixed code typos.

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-08-28 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls