ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.