Partner to the last snippet; simply grabs all those files & places them where they should be. Could use some error checking & other features, but then it wouldn't be a snippet... ;-) Update Helps to reload your config file & check for errors before posting to perl monks...
#!/usr/bin/perl # another quick one to add all those # zone files from flatdns.pl into something # useful, like say, a named.conf. Backs up # your named.conf first. $|++; use strict; use Getopt::Std; use File::Copy; use POSIX; my(@dnsdbs,$file,%args,$dbloc,$tmp); getopt('f:hd:s:',\%args); if(!defined $args{'f'} || !defined $args{'d'} || defined $args{'h'}) { print <<EOU; Synopsis: append-dns.pl [options] Where options are: -f the name of the input file [normally named.conf] -d the location of the zone files -s Make these zones slaves instead (must provide a master). -h print this help message. EOU exit; } $file = $args{'f'}; $dbloc = $args{'d'}; copy($file,$file . strftime("%Y%m%d-%T",localtime(time()))) or die "Ca +nnot copy file $file: $!"; open(DNSCF,'>>',$file) or die "Cannot open $file: $!"; @dnsdbs = glob("$dbloc*.{com,net,org,biz,us}"); for(@dnsdbs) { $tmp = $_; $tmp =~ s/\/.*\///; $tmp =~ s/db\.//; print DNSCF "zone $tmp {\n"; if(!defined $args{'s'}) { print DNSCF "\ttype master;\n"; print DNSCF "\tfile \"$_\";\n"; print DNSCF "};\n"; } else { print DNSCF "\ttype slave;\n"; print DNSCF "\tfile \"$_\";\n"; print DNSCF "\tmasters {\n"; print DNSCF "\t\t" . $args{'s'} . ";\n"; print DNSCF "\t};\n};\n"; } } close(DNSCF);

In reply to append-dns.pl by straywalrus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.