"Inappropriate file type or format" error when accessing berkely DB
file via perl
mark
mark.rowlands at mypost.se
Thu May 4 04:37:34 UTC 2006
I am trying to access my squidguard berkely db files via perl and DB_File
(as per the SquidGuard docs)
When I run the following perl snippet
#!/usr/bin/perl
use DB_File;
my (%url,%domain);
$DB_BTREE->{compare} = \&domainmatch;
my $domain_db =
tie(%domain, "DB_File", "/var/db/squidGuard/warez/domains.db", O_CREAT|
O_RDWR, 0664, $DB_BTREE) || die("domains.db: $!\n");
$domain_db->put(".six.com","") unless(exists($domain{"six.com"}));
$domain_db->sync; # Seems to only sync the last change.
undef($domain_db); # Destroy the object
untie(%domain); # Sync and close the file and undef the hash
The following is returned
domains.db: Inappropriate file type or format
When I do a file /var/db/squidGuard/warez/domains.db
the following is displayed
/var/db/squidGuard/warez/domains.db: Berkeley DB
(Btree, version 8, native byte-order)
When I create a db with perl
#!/usr/bin/perl -w
use strict;
use DB_File;
my %database;
tie %database, 'DB_File', "createdb.dat"
or die "Can't initialize database: $!\n";
untie %database;
exit;
then
file createdb.dat
reveals :-
createdb.dat: Berkeley DB 1.85 (Hash, version 2, native byte-order)
I suspect the version 2 / version 8 is the srouce of my innappropriate file
type or format error!
So ...... I tried reinstalling DB_file guessing that it had some kind of
dependency on DB3.. Thsi had no effect. I tried reinstalling Perl itself.
Also no effect.
So I am a bit stuck, How do I get DB_File to play nice with DB3 or should I be
trying some other method to access these files.
Relevant Ports installed
db3-3.3.11_2,1
bsdpan-DB_File-1.814
p5-DBD-mysql41-3.0002
squid-2.5.13
squidGuard-1.2.0_1
perl-5.8.8
possible related ports
dbh-1.0.24_1
gdbm-1.8.3_2
p5-DBI-1.50
FreeBSD pcmarpxy.mwrwin2k.se 6.0-STABLE FreeBSD 6.0-STABLE #1: Fri Dec 23
11:58:53 CET 2005 root at pcmarpxy.mwrwin2k.se:/usr/obj/usr/src/sys/MARK
i386
More information about the freebsd-questions
mailing list