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

Dear All,

     I have a problem with my berkeley db file. I am trying to tie the berkeley db file with the perl hash. But i am unable to tie, i can't even getting the error messages also.Here is my code,

my $file = "/home/doc57/data/administrators.db"; tie( %hash, 'DB_File::Lock', $file, O_RDONLY, 0666, $DB_TREE, 'read' +) || die ( "db file open error ..:$!:");

    But, i can able to tie another files using the same options. Moreover the same code works for the same file in different host.

     My current system is redhat 7.1. The other host where it is working is RH enterprise 4.0.


Here is the file permissions for the file.
-rw-r--r-- 1 doc57 Group1 8192 Sep 29 11:46 /home/doc57/dat +a/administrators.db

The issue is the code is working with same permissions and same code in another host. What could be the reason ? I am sticking with this issue for two days. Please, Share your ideas in this issue.

Thanks in advance.

Regards,
S.Venni Rajan.
"A Flair For Excellence."
                -- BK Systems.

Replies are listed 'Best First'.
Re: Tie Failed for berkeley DB file
by PodMaster (Abbot) on Jan 13, 2006 at 05:59 UTC
    Get ahold of the various berkeleydb utilities ( db_archive, db_checkpoint, db_deadlock, db_dump, db_load, db_printlog, db_recover, db_stat, db_upgrade, db_verify ) and investigate :)(don't forget $DB_File::db_version and DB_File pod for hints)

    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.

      Runnind db_upgrade or db3_upgrade on the file, helps in opening the file on Linux. However, it no more works on Solaris.
        However, it no more works on Solaris.

        That is to be expected, the files aren't backwards compatible, that is why BerkeleyDB provides an upgrade utility

Re: Tie Failed for berkeley DB file
by Aristotle (Chancellor) on Jan 13, 2006 at 05:43 UTC

    How about you tell us what the error message says?

    Makeshifts last the longest.

      I am not getting any error messages. It just prints the empty string.

      Regards,
      S.Venni Rajan.
      "A Flair For Excellence."
                      -- BK Systems.

        There is nothing in the code you showed that prints anything. There is only a die. Does the code not die at that point? If not, what code prints the empty string? Do you mean you get an empty string value when you look up a key? Do all lookups produce the same result regardless of key? Was the DBM file generated by the same setup that is failing to read it or did you copy it from elsewhere?

        Makeshifts last the longest.

Re: Tie Failed for berkeley DB file
by mitd (Curate) on Jan 13, 2006 at 05:47 UTC
    Like Aritotole said, but taking a wild stab in the dark: What are the permissions on the parent directory?

    mitd-Made in the Dark
    I've always been astonished by the absurd turns
    rivers have to make to flow under every bridge.

      Here is the parent directory permissions,
      $> ls -ld data drwxrwxr-x 21 doc57 shaklee 8192 Jan 12 15:57 data $>

      I can able to tie other db files in the same directory. Also the same setting ( permissions , options and code ) working for that file in other host ( RH enterprise 4.0 ).

      Is that any thing with the OS issue ?


      Regards,
      S.Venni Rajan.
      "A Flair For Excellence."
                      -- BK Systems.
        Hmmm ... once again it sure would help if you could show us the output from $!.

        mitd-Made in the Dark
        I've always been astonished by the absurd turns
        rivers have to make to flow under every bridge.

        I am having the same problem. It works fine for other files, other platforms. But one file on linux machine fails to tie. It does not even print the error message. Please let me know if you found the solution.