Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Reading Sendmail .db files

by waswas-fng (Curate)
on Nov 22, 2004 at 19:46 UTC ( #409705=note: print w/replies, xml ) Need Help??


in reply to Reading Sendmail .db files

Try makemap...

makemap -u hash access.db
Will dump a HASH type sendmail db to plaintext, you could also use btree instead. And then you can recreate the map from the text source file:
makemap hash access.db < access.txt


-Waswas

Replies are listed 'Best First'.
Re^2: Reading Sendmail .db files
by Maddingue (Sexton) on Nov 23, 2004 at 08:50 UTC
    Oh thanks, that works. Although I'd still like to know why the Perl scripts (and the short C program) I wrote didn't work. Are the .db files Sendmail create so special that another program can't read them? But, thank you very much for the command, I didn't know the -u option of makemap. At least I can see the content of its db and check what is inside.

      With regard to BerkelyDB => RTFM. You can't just make syntax up and expect it to work. This works fine.....

      [root@www mail]# cat reader.pl #!/usr/bin/perl use BerkeleyDB; tie %hash, 'BerkeleyDB::Hash', -Filename => $ARGV[0] or die "can't read file '$ARGV[0]': $!"; print map { " $_ => $hash{$_}\n" } sort keys %hash; [root@www mail]# ./reader.pl virtusertable.db @blech.com.au => blech.com.au [snip]

      With regard to your second example, once again you need to RTFM. You have a syntax error in that DB_HASH is a $PERL_SCALAR not a constant as you assume. I would agree with your C style brain that it should logically be a constant but I did not design the interface.....

      tie %hash, 'DB_File', $file, O_RDONLY, 0666, $DB_HASH

      cheers

      tachyon

        Well, I did RTFM of both modules, but missed some parts apparently.. Like $DB_HASH instead of DB_HASH. I'll blame DB_File API for mixing up C-style constants and Perl-style constants. I can also blame myself for not copy&paste the code like I did for the BerkeleyDB example. It seems that it was the -Property => DB_DUP | DB_DUPSORT that prevent the code to run. When I comment this option, the script works. Well, thanks anyway.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://409705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2021-01-27 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?