aboutsummaryrefslogtreecommitdiff
path: root/nsdbimport/nsdbimport
diff options
context:
space:
mode:
Diffstat (limited to 'nsdbimport/nsdbimport')
-rwxr-xr-xnsdbimport/nsdbimport22
1 files changed, 19 insertions, 3 deletions
diff --git a/nsdbimport/nsdbimport b/nsdbimport/nsdbimport
index dc93c6d..7c72f71 100755
--- a/nsdbimport/nsdbimport
+++ b/nsdbimport/nsdbimport
@@ -36,10 +36,12 @@ my $progname = basename($0); # This script name;
my $progdescr = "converts BIND zone files to SQL database";
my $debug;
my $dry_run;
+my $verbose;
my $bind_directory;
my $bind_config;
my $dbd;
my $generate_seen;
+my $record_count;
sub error {
my $msg = shift;
@@ -61,6 +63,12 @@ sub abend {
exit $code;
}
+END {
+ if ($record_count and ($verbose or $?)) {
+ print "$progname: $record_count records processed successfully\n";
+ }
+}
+
my %config;
sub readconfig {
@@ -195,6 +203,7 @@ sub sql_query {
$dbd->do($q)
or abend(EX_UNAVAILABLE, $dbd->errstr."\nFailed query: $q");
}
+ ++$record_count;
}
# generate($expr, $origin, $file, $line);
@@ -413,6 +422,7 @@ GetOptions("h" => sub {
"bind-config|from-config=s" => \$bind_config,
"origin=s" => \$origin,
"debug|d+" => \$debug,
+ "verbose|v+" => \$verbose,
"dry-run|n" => \$dry_run,
"config|c=s" => \$conffile) or exit(EX_USAGE);
@@ -466,7 +476,7 @@ $arg = 'DBI:mysql'.$arg;
$dbd = DBI->connect($arg, $config{user}, $config{password},
{ PrintError => 0, AutoCommit => 1})
- or exit(EX_UNAVAILABLE);
+ or abend(EX_UNAVAILABLE, "can't connect to the database: ".$DBI::errstr);
if (defined($bind_config)) {
abend(EX_USAGE, "extra input files") if $#ARGV >= 0;
@@ -493,7 +503,7 @@ nsdbimport - import data from BIND-compatible zone files to SQL database
=head1 SYNOPSIS
B<nsdbimport>
-[B<-dhn>]
+[B<-dhnv>]
[B<-C> I<DIR>]
[B<-c> I<FILE>]
[B<--bind-config=>I<FILE>]
@@ -504,7 +514,8 @@ B<nsdbimport>
[B<--from-config=>I<FILE>]
[B<--help>]
[B<--origin=>I<ZONE>]
-[B<--usage>]
+[B<--usage>]
+[B<--verbose>]
[I<ZONEFILE>...]
=head1 DESCRIPTION
@@ -557,6 +568,11 @@ Don't actually import data, print what would have been done instead.
Set initial origin. Useful when processing individual files.
+=item B<-v>, B<--verbose>
+
+Verbose mode. Report count of successfully processed records at the
+end of the run.
+
=back
The following options cause the program to display informative text and

Return to:

Send suggestions and report system problems to the System administrator.