TQuid has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to recover data from a trashed website; I believe the .pag & .dir files that are its databases are intact, but they came from a rather musty BSDI 2.x system. They were evidently created with old-fashioned dbmopen(). Moving the files to a BSDI 4.0.1 system has eliminated the "file too large" errors, but now trying to print them results in nothing at all. I'm using this wee script:

#!/usr/bin/perl5 -w dbmopen(%db, 'member.dir', 0644) or die "Can't open member: $!\n"; foreach $i (keys %db) { print "$i ==> $db{$i}\n"; }

It seems to make little difference whether I put in 'member', 'member.pag', or 'member.dir', as above. The script doesn't die, but neither does it print anything out. Trying to use DB_File and NDBM_File more directly doesn't seem to have panned out. A 'file member.dir' says this is an NDBM 1.x or GDBM file, and being on BSDI, I suspect it's probably NDBM. I've been unable to get GDBM_File working on the new system, though it appears to have gdbm installed. I'm going to pursue that tack a bit now, but thought I would post here and check back now and again to see if I'm being thoroughly stupid. Is there any hope?

--TQuid

Replies are listed 'Best First'.
Re: .pag and .dir - what db format??
by maverick (Curate) on Aug 09, 2000 at 00:00 UTC
    I used to work on an old AIX box that made dbms that way. And for the life of me I can't remember what format they are. I can tell you what they aren't. They're aren't Berkeley or GNU. If you can get them on a Linux box, you can run "file whatever" and it can tell you what they are. There may also be some way of getting perl to tell you the compile time options it has, because the default DBM library is system dependant.

    Hope this helps...

    /\/\averick

Re: .pag and .dir - what db format??
by Speedfreak (Sexton) on Aug 09, 2000 at 01:56 UTC

    To add another spanner/clue to this.

    I had several database files like this on a Solaris system. I discovered .db files are hash databases and .dir and .pag are dbms.

    For example, on sendmail we have a aliases file called oddly enough, aliases which has the following format:

    alias: user1 alias2: user2, user3

    To create the .pag and .dir we would use:

    #makemap dbm alias < alias

    Which would result in aliase.pag and alias.dir being made from the alias text file.

    For the .db files, the command was:

    #makemap hash alias < alias

    Making alias.db.

    However, in attempting to get info from these files, I found typing:

    #strings alias.dir
    #strings aliase.pag

    was a good way of just getting the ascii strings out.

    Maybe you could do this, piping the output to a text file before processing in perl.

    - jed

    P.S: In the above the # is not to be typed, it represents the shell prompt.

Re: .pag and .dir - what db format??
by chromatic (Archbishop) on Aug 09, 2000 at 07:36 UTC
    If you're using Apache, a program named dbmmanage should be installed. It lets you store usernames and passwords in a DBM file for HTTP authentication. Something like dbmmanage <filename without extension> view should get the information for you.

    Perl content: dbmmanage is a Perl script. :) Not terribly pretty, but readable.

Re: .pag and .dir - what db format??
by Anonymous Monk on Aug 06, 2001 at 13:12 UTC