Re: Inappropriate file type or format error when accessing berkely DB file via perl

2006-05-04 Thread Parv
in message [EMAIL PROTECTED],
wrote mark thusly...

 I am trying to access my squidguard berkely db files via perl  and
 DB_File (as per the SquidGuard docs)
...
 #!/usr/bin/perl
 use DB_File;
 my (%url,%domain);

   $DB_BTREE-{compare} = \domainmatch;
^ ^ ^ ^ ^ ^
^ ^ ^ ^ ^ ^
I suppose you have domainmatch() sub defined somewhere used in this
file but omitted from your post?


   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
  ^ ^ ^ ^ ^ ^
  ^ ^ ^ ^ ^ ^
So the program is dying due to failure in tie()ing.

Did you check if both SquidGuard  DB_File are linked with the same db
library?

 When I do a file /var/db/squidGuard/warez/domains.db
...
 /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;
...
 file createdb.dat
...
 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!

mach::DB_File(3) lists ...

  Using DB_File with Berkeley DB version 2 or greater

  Although DB_File is intended to be used with Berkeley DB version 1,
  it can also be used with version 2, 3 or 4. In this case the
  interface is limited to the functionality provided by Berkeley DB
  1.x. Anywhere the version 2 or greater interface differs, DB_File
  arranges for it to work like version 1.


... so it is not surprising that, in your second case, the db file
created is of version 1.x.  (Note also that since you had not
specified that you wanted a BTree db type, the type is hash.)


 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.
...
 Relevant Ports installed

 db3-3.3.11_2,1
 bsdpan-DB_File-1.814
...
 perl-5.8.8

DB_File (same version that you had installed separately) is included w/
Perl (at least in 5.8.8).


Well, i just searched Google Groups for 'perl DB_File db3
Inappropriate file type or format' which presented ...

  
http://groups.google.com/group/fa.freebsd.questions/browse_thread/thread/783254b63fbba089/3a8af6e2d78282f9



  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Inappropriate file type or format error when accessing berkely DB file via perl

2006-05-04 Thread mark
 P5-BerkeleyDB  proved to be a functional  solution for me at any rate, many 
thanks for the pointer.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Inappropriate file type or format error when accessing berkely DB file via perl

2006-05-03 Thread mark
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 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/MARK  
i386


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]