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]"

Reply via email to