Re: Problem using DB_File
- From: "Paul Marquess" <paul.marquess@xxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 15:35:37 +0100
"Andras Malatinszky" <nobody@xxxxxxxx> wrote in message
news:BOO8e.2262$lz1.1709@xxxxxxxxxxxxx
> I'm trying to read a database that I created using the DB_File module on
> a Linux box and then transferred to a Windows box. Here's a simplified
> setup illustration of my problem:
>
> First, on the Linux box I ran this script:
>
> #!/usr/bin/perl -w
> use strict;
> use DB_File;
>
> tie my %db, 'DB_File', 'database.db';
>
> $db{'blue'}='azul';
>
> untie %db;
>
>
> As expected, it creates a file called database.db, and when I run this
> script:
>
> #!/usr/bin/perl -w
> use strict;
> use DB_File;
>
> tie my %db, 'DB_File', 'database.db' or die $!;
>
> print $db{'blue'};
>
> untie %db;
>
>
> I get the word "azul" printed on the screen as expected.
>
> So now I FTP database.db and the second script over to my Windows box
> and run the script. What I get is an error message saying "Died at
> read.pl line 5." (Line 5 being the one with the tie.)
>
> Why is this happening? Why am I not getting anything in the $! variable?
> Does DB_File work with different formats on Linux and Windows? Any
> suggestions for addressing this, short of dumping the database on the
> Linux box and rebuilding it on the Windows box?
If compatible versions of Berkeley DB have been used to build DB_File on
both platforms, the database files are portable. In your case I would guess
that they aren't compatible.
Run this on the Linux box to see what version of Berkeley DB was used to
build DB_File
perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'
and this on the windows box
perl -e "use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}"
If the version numbers are identical, your problem lies elsewhere (possibly
an ASCII FTP).
If they are different, then you need to know which versions of Berkeley DB
are compatible with each other. To find that out, run the dbinfo script that
comes with DB_File against the database file on your Linux box. This script
will tell you what versions of Berkeley DB can be used to access the
database file. Usage is
perl dbinfo database_file
Assuming you have incompatible versions of Berkeley DB, you options are
1. rebuild DB_File on one/both platforms to use the same version of Berkeley
DB.
2. use the db_dump/db_load utilities that come with Berkeley DB to dump and
load the database.
Paul
.
- Follow-Ups:
- Re: Problem using DB_File
- From: Andras Malatinszky
- Re: Problem using DB_File
- References:
- Problem using DB_File
- From: Andras Malatinszky
- Problem using DB_File
- Prev by Date: Re: Problem using DB_File
- Next by Date: Re: Net::SNMP - Newbie Help
- Previous by thread: Re: Problem using DB_File
- Next by thread: Re: Problem using DB_File
- Index(es):
Relevant Pages
|
|