/usr/bin/dbf_dump is in libdbd-xbase-perl 1:1.05-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
use XBase;
use Getopt::Long;
use strict;
$^W = 1;
my $stdin = 0;
if (defined $ARGV[$#ARGV] and $ARGV[$#ARGV] eq '-') {
$stdin = 1; pop @ARGV;
}
my %options;
Getopt::Long::GetOptions( \%options,
'help', 'version', 'info', 'rs=s', 'fs=s', 'undef=s', 'fields=s',
'nomemo', 'memofile=s', 'memosep=s', 'table',
'SQL',
) or exit;
if (defined $options{'version'}) {
print "This is dbf_dump version $XBase::VERSION.\n";
exit;
}
if ($stdin) {
push @ARGV, '-';
$options{'nomemo'} = 1;
}
if (@ARGV == 0 or defined $options{'help'}) {
die <<'EOF';
Usage: dbf_dump [ options ] files
where the options specify
--rs output record separator (default newline)
--fs output field separator (default colon)
--fields comma separated list of fields to print (default all)
--undef what to print for NULL values (default empty string)
--memofile specifies unstandard name of attached memo file
--memosep separator for dBase III dbt's (default \x1a\x1a)
--table output in nice table format (needs Data::ShowTable)
all having as parameter a string; and also
--nomemo do not try to read the memo (dbt/fpt) file
--info only print info about the file and fields
--version print version of the XBase library
EOF
}
my %addopts = ();
if (defined $options{'nomemo'} or defined $options{'info'}) {
$addopts{'ignorememo'} = 1;
}
$addopts{'memosep'} = $options{'memosep'};
$addopts{'memofile'} = $options{'memofile'};
if (defined $options{'info'}) {
$addopts{'ignorebadheader'} = 1;
}
my $file;
for $file (@ARGV) {
my $table = new XBase 'name' => $file, %addopts;
if (not defined $table) {
print STDERR XBase->errstr;
next;
}
if (defined $options{'info'}) {
if (not defined $options{'SQL'}) {
print $table->header_info;
} else {
my $name = $file;
$name =~ s!^.*/|\.dbf$!!ig;
print "create table $name (\n";
my @names = $table->field_names;
my %conv = qw!
C varchar
N numeric
F numeric
L boolean
M blob
D date
T time
!;
my @types = map { $conv{$_} } $table->field_types;
my @lengths = $table->field_lengths;
my @decimals = $table->field_decimals;
for (my $i = 0; $i < @names; $i++) {
print "\t$names[$i] $types[$i]";
if ($types[$i] eq 'blob') {
$lengths[$i] = $decimals[$i] = undef;
}
if ($lengths[$i] or $decimals[$i]) {
print "($lengths[$i]";
print ", $decimals[$i]" if $decimals[$i];
print ")";
}
if (defined $names[$i+1]) {
print ',';
}
print "\n";
}
print ")\n";
}
} else {
$table->dump_records(%options) or print STDERR $table->errstr;
}
$table->close;
}
1;
__END__
=head1 NAME
dbf_dump - Dump the record of the dbf file
=head1 FORMAT
dbf_dump [options] files
where options are
--rs output record separator (default newline)
--fs output field separator (default colon)
--fields comma separated list of fields to print (default all)
--undef string to print for NULL values (default empty)
--memofile specifies unstandard name of attached memo file
--memosep separator for dBase III dbt's (default \x1a\x1a)
--nomemo do not try to read the memo (dbt/fpt) file
--info print info about the file and fields
with additional --SQL parameter, outputs the SQL create table
--version print version of the XBase library
--table output in nice table format (only available when
Data::ShowTable is installed, overrides rs and fs)
=head1 SYNOPSIS
dbf_dump -fields id,msg table.dbf
dbf_dump -fs=' : ' table
dbf_dump --nomemo file.dbf
ssh user@host 'cat file.dbf.gz' | gunzip - | dbf_dump -
=head1 DESCRIPTION
Dbf_dump prints to standard output the content of dbf files listed. By
default, it prints all fields, separated by colons, one record on
a line. The output record and column separators can be changed by
switches on the command line. You can also ask only for some fields to
be printed.
The content of associated memo files (dbf, fpt) is printed for memo
fields, unless you use the C<--nomemo> option.
You can specify reading the standard input by putting dash (-) instead
of file name.
=head1 AVAILABLE FROM
http://www.adelton.com/perl/DBD-XBase/
=head1 AUTHOR
(c) 1998--2011 Jan Pazdziora.
=head1 SEE ALSO
perl(1); XBase(3pm); index_dump(1p)
=cut
|