| Jeff Pang 2006-02-08, 9:06 am |
| hello,
In this situation you usually need to analyse the syntax of 'named.conf'.It=
is maybe a hard work based on the complexity of your file.Here,you can mat=
ch the begin of 'view external {' block and add the additional lines from t=
hat location.I would do the modification as following:
my $cfgFile =3D "/etc/named.conf";
open (HD,$cfgFile) or die "$!";
my @config =3D <HD>;
close HD;
open (NAMEDCONF,">",$cfgFile) or die "$!";
for (@config)
{
print NAMEDCONF $_;
if (/view external \{/)
{
print NAMEDCONF "zone \"", $zone, "\" {\n";
print NAMEDCONF "\ttype master;\n";
print NAMEDCONF "\tfile \"", "hosts.$zone", "\";\n";
print NAMEDCONF "};\n";
}
}
close NAMEDCONF;
Hope that helps.
-----Original Message-----
>From: bsd <bsd@todoo.biz>
>Sent: Feb 8, 2006 7:14 PM
>To: Liste Perl <beginners@perl.org>
>Subject: Inserting data inside {}; --> aka "script to update named.conf h=
andling zone"
>
>Hello,
>
>
>I am trying to use a modified version of the script produced by =20
>cricket Liu (DNS & BIND Cookbook) :
>
=20[color=darkred]
>
>
>A version that will allow me to place the output of the printed =20
>statement (NAMEDCONF) inside the statement :
>
>
>
>For the moment when I execute the script, my NAMEDCONF statments ends =20
>outside of the last "};" and I need It inside (because of zone =20
>handling matter.
>
>I am a real beginner so any clue will be welcome.
>
>
>Thanks a lot --
>
>
>
> ________________________________________
________
>?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=
=A5?=BB=A7
> =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
>Gregober ---> PGP ID --> 0x1BA3C2FD
>bsd @at@ todoo.biz
> ________________________________________
________
>?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=A5?=BB=A7?=BB=
=A5?=BB=A7
> =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
>
>
>
>
>--
>To unsubscribe, e-mail: beginners-unsubscribe@perl.org
>For additional commands, e-mail: beginners-help@perl.org
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com
|