Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

DB_FILE from LINUX to Windows

by kleucht (Beadle)
on Oct 13, 2003 at 23:34 UTC ( #298977=perlquestion: print w/replies, xml ) Need Help??
kleucht has asked for the wisdom of the Perl Monks concerning the following question:

I'm struggling trying to get a LINUX created BerkleyDB file opened and used in the Windows environment.

I got the DB_File perl module installed using PPM on the Windows 2000 machine. That worked great. Now without any DB file in the directory when I run my program, it creates the "filename.db" file and manipulates it just fine. But when I copy my original "filename.db" file into it's place ... the one that was actually created on a Linux machine, it tells me it cannot open the file.

I've FTP'd the DB file using both BINARY and ASCII, and both give me the same error.

I've messed with the file permissions on the DB file on the Windows machine and the file that it is giving me an error on has the exact same permissions as the file that the perl script created & modified successfully, so it cannot be a permission problem.

Is there a potential disconnect with the LINUX created file and the windows perl DB_File module? Can the Windows Perl module DB_File open and modify a file that was created on a Linux machine?

Thanks for any help you can give!
Kurt (kleucht)

Replies are listed 'Best First'.
Re: DB_FILE from LINUX to Windows
by iburrell (Chaplain) on Oct 14, 2003 at 00:12 UTC
    The Berkeley DB file format changed with different versions of the library. The file format should be compatible for the same version of the library on different platforms.

    For example, the DB_File that comes with Red Hat 7.3 is linked against db 3.3. I bet the Windows 2000 version has an earlier version of the library compiled into it. It can't open databases created with the newer versions of the library.

    Try using the file command on databases created on Linux and Windows. It will identity the version. If the Windows version is new enough, you may be able to convert the files with db_dump and db_load.

      I bet the Windows 2000 version has an earlier version of the library compiled into it. It can't open databases created with the newer versions of the library.
      That would depend. The DB_File on my repository ;) yields something like
      use DB_File; warn $DB_File::VERSION; warn $DB_File::db_version; die $DB_File::db_ver; __END__ 1.805 at - line 2. 4.1 at - line 3. 4.001025 at - line 4.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Re: DB_FILE from LINUX to Windows
by tilly (Archbishop) on Oct 14, 2003 at 05:04 UTC
    Failing all else, I recommend defining a text-file format that you can dump to and load from with simple scripts. That will enable you to easily migrate data across platforms and across versions of the dbm.

    Then I strongly recommend that you make taking a text backup part of your regular backup strategy. (If you don't have a regular backup strategy, then I recommend starting one before you find that you needed it...)

      What tilly said. I had this problem once, a while back, and the only way to get the data across was to extract to text, ftp, and put it into a new, created-n-the-Windows-machine database. It wasn't pretty, God knows, and it denied laziness; however, it worked, which is the important thing.

      Ain't enough 'O's in 'stoopid' to describe that guy.
      - Dave "the King" Wilson

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://298977]
Approved by valdez
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-03-30 12:09 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (356 votes). Check out past polls.