Permalink
Browse files

Update README and include example rndc.pl script that behaves somewha…

…t like rndc utility.
  • Loading branch information...
1 parent e8910fd commit 8857af4f9ffae30b7237da356b24a5513565639c @wolfsage committed Jan 3, 2013
Showing with 65 additions and 3 deletions.
  1. +1 −3 README
  2. +64 −0 scripts/rndc.pl
View
4 README
@@ -10,8 +10,6 @@ To play with Net::RNDC (Uses Dist::Zilla):
dzil build
-WARNING: Error checking is very lax right now, so if you're key is wrong
- or BIND sends a weird response, you'll get some very interesting
- warnings. I hope to add tests and fix all of this soon :)
+For an example usage, see scripts/rndc.pl.
-- Matthew Horsfall (alh)
View
64 scripts/rndc.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+# Example rndc script
+
+use strict;
+use warnings;
+
+use FindBin qw($Bin);
+
+use lib "$Bin/../blib", "$Bin/../lib";
+
+use Net::RNDC;
+
+my $key = shift;
+my $host = shift;
+my $cmd = shift;
+
+unless ($cmd) {
+ die "Usage: $0 <key> <host> <command>\n";
+}
+
+my $rndc = Net::RNDC->new(
+ host => $host,
+ key => $key,
+);
+
+if ($rndc->do($cmd)) {
+ print $rndc->response . "\n";
+} else {
+ print "Error: " . $rndc->error . "\n";
+}
+
+=head1 NAME
+
+rndc.pl - Example rndc script for communicating with BIND.
+
+=head1 SYNOPSIS
+
+Usage:
+
+ ./rndc.pl <key> <host> <command>
+
+IE:
+
+ ./rndc.pl aabc localhost status
+
+=head1 DESCRIPTION
+
+This example script shows usage of L<Net::DNS>. It requires the rndc key for
+communicating with BIND, the hostname of the BIND to communicate with, and the
+command in question.
+
+On success it outputs the response from BIND, otherwise an error prefixed with
+"Error: ".
+
+=head1 AUTHOR
+
+Matthew Horsfall (alh) <WolfSage@gmail.com>
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut

0 comments on commit 8857af4

Please sign in to comment.