Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello all, As I am trying to debug a quite hairy Sendmail problem, I'd like to read its virtuser.db (it's the DB for virtual users). Searching CPAN a module to read Berkeley databases, I found BerkeleyDB and wrote this little script:
#!/usr/bin/perl use BerkeleyDB; my $file = shift || die "usage: $0 file"; %hash = (); my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $file, -Flags => DB_RDONLY, -Property => DB_DUP | DB_DUPSORT or die "can't read file '$file': $!"; my $ref = $db->db_stat; print "db info: \n", map{" - ${_}: ".$ref->{$_}.$/} keys %$ref; print "db contains ", scalar(keys %hash), " entries\n"; print map { " $_ => $hash{$_}\n" } sort keys %hash;
The script fails at the tie() but with no error in $! Then I tried with DB_File, and wrote this script:
#!/usr/bin/perl use DB_File; my $file = shift || die "usage: $0 file"; %hash = (); tie %hash, 'DB_File', $file, O_RDONLY, 0666, DB_HASH or die "can't read file '$file': $!"; print "$file has ", scalar(keys %hash), " entries\n"; print map { " $_ => $hash{$_}\n" } sort keys %hash;
which also fails with the following error:
type parameter is not a reference at /usr/lib/perl5/5.6.1/i386-linux +/ line 262.
So.. my question is: if anyone has an experience with one of these modules, or with Sendmail .db files, or best, already has a script that dump the content of a Berkeley DB in human readable form, I'm all for it! (I know dbdump included with BerkeleyDB, but it does not dump the content in human readable form). Thanks in advance for anyone who has an idea

In reply to Reading Sendmail .db files by Maddingue

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (5)
    As of 2021-01-27 23:01 GMT
    Find Nodes?
      Voting Booth?