Invoking cdbdump from a bash script, hanging
Chris Wilkes <[email protected]> Wed, 18 Dec 2002 21:23:16 -0800
| Newsgroups | gmane.comp.djb.cdb |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm making a CDB database with really simple entries: an MD5 hash of
an email's body and a 0 or 1 if it is non-spam or spam. A typical
transaction would be asking if an MD5 entry is in there. A non-typical
one would be changing an entry's value from 0 to 1 or vice versa.
I was going to use the Perl module CDB_File but it gets pretty slow
when you have 50k+ entries.
Then I thought about using cdbdump as the database is pretty simple.
This works when I'm on the command line:
cdbdump < data.cdb
| sed 's/286466f8cabcfd520a78b337a5b69aa5->1/286466f8cabcfd520a78b337a5b69aa5->0/'
| cdbmake data.cdb data.cdb.71952
and is much faster than the Perl way. So I through it into a script,
here's the meat of it:
#!/bin/sh
bindir="/usr/local/bin"
DATA='data.cdb'
command="$bindir/cdbdump < $DATA";
echo "$command";
`$command`;
Running under strace you can see it hang waiting for STDIN. I'm not
sure what's going wrong here. The above works with cdbget so I know I'm
not crazy.
Anyone use cdbdump in a shell script? Is there a better way?
Chris