LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2002, 10:56 PM   #1
Gardener
LQ Newbie
 
Registered: Aug 2002
Location: Stockholm, Sweden
Distribution: Red Hat 7.x
Posts: 8

Rep: Reputation: 0
Reading Berkeley DB 1.85 in perl


I have a bunch of databases from an old forum system that I really want to extract the information from. Unfortunately the version of perl that I run now can't seem to load these files at all.

When running file on the db files I get this:
Code:
bash-2.05# file data/eon.db
data/eon.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
The old script used this to load the db:
Code:
dbmopen (%DB, "$db_dir/$db", 0644)
I'm using Perl 5.6.1 at the moment, installed from an rpm, the old perl version must have been 5.004 or maybe even earlier, from RH5.x I believe.

I've tried using tie together with different DB types, like DB_File, GDBM_File and SDBM_File but nothing seems to work.

Does anyone know what I'm doing wrong or have any insight at all that could help me?
 
Old 09-23-2002, 10:26 AM   #2
TheLinuxDuck
Member
 
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
The message "data/eon.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)" doesn't necessarily sound like an error code. I am assuming that file is a perl script? Can you post the code segment related to opening and reading the DB?
 
Old 01-25-2003, 07:14 PM   #3
Gardener
LQ Newbie
 
Registered: Aug 2002
Location: Stockholm, Sweden
Distribution: Red Hat 7.x
Posts: 8

Original Poster
Rep: Reputation: 0
The command file is the standard program to determine a file type, I showed the output to show what type of DB it is.

The db files were created by a very old version of the forum system called WWWThreads and I want to extract the information to insert it into the MySQL database the new version uses. The old version is very old and hasn't been supported by the programmer for a long time.

Here is the part of the script that is trying to read this db file (this script used to work on an old perl version, but it broke when I upgraded a long time ago):
Code:
use vars qw(%DB %BI $board_index);
use strict;
use CGI;
use DB_File;

        my $db_dir     = '/path/to/data';
        my $db         = 'dbname';

        dbmopen (%DB, "$db_dir/$db", 0644) or die "Can't open board: $db. Reason
        foreach (reverse 0 .. $DB{'TOTAL'}) {   
                if ($DB{$_}) {
                        @data = split (/\t/, $DB{$_});
                        if ($data[0] eq "Main") {
....
                        }
                }
        }
        dbmclose (%DB) or die "Can't close board: $db. Reason: $!";
I've removed a lot of the code to save space, the problem is that dbmopen won't recognize the database at all.
 
Old 01-22-2015, 12:26 AM   #4
shachter
Member
 
Registered: Jul 2007
Posts: 101

Rep: Reputation: 2
This 13-year-old discussion was never closed. No answer to the question
was ever posted. But I am having the same problem as the original
poster -- specifically, I am trying to read an aliases.db file that
was, apparently, created by an old sendmail program. The "file" command
reports:

Berkeley DB (Hash, version 5, native byte-order)

and this is, apparently, too old for DB_File to read.

Did you ever solve your original problem? If so, please
tell us how. If you do not think that this 13-year-old discussion
is of general interest, please do me the kindness of sending me
electronic mail -- jay at m5 dot chicago dot il dot us.

Thank you in advance for your reply.
 
Old 01-28-2015, 07:44 AM   #5
Gardener
LQ Newbie
 
Registered: Aug 2002
Location: Stockholm, Sweden
Distribution: Red Hat 7.x
Posts: 8

Original Poster
Rep: Reputation: 0
I'm sorry, I never found a solution to this issue.
 
Old 01-28-2015, 01:37 PM   #6
SoftSprocket
Member
 
Registered: Nov 2014
Posts: 399

Rep: Reputation: Disabled
Glibc provides older interfaces to bdb (see man dbopen). You could try opening the file using the C glibc interface.
 
Old 01-28-2015, 06:16 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
I suggest that you inquire at http://www.perlmonks.org.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql reading via Perl DBI ivanatora Programming 2 03-21-2007 04:03 AM
Perl - Reading Real Time streams vitoal18t Programming 10 05-18-2005 06:59 AM
Need Help in Reading a rather complex textile in perl!! domquem Programming 9 01-03-2005 01:39 PM
Perl and Berkeley db zolley Linux - Newbie 0 06-07-2004 05:43 AM
perl reading pdf,ps,txt j-ray Programming 1 02-04-2003 10:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration