[Spambayes] Win32 Command Line

Tony Meyer tameyer at ihug.co.nz
Fri Oct 8 00:09:42 CEST 2004

> Thanks for the read.  Most of the material is for *nix in 
> that link.

True, although the process itself is probably the same, and the SpamBayes
tools to use are the same.

> I spent a considerable amount of the afternoon trying to make 
> everything work from the command line.  After making every
> conceivable newbie error in the book, I did manage to make
> it do something.  Eventually, I tried to use sb_mboxtrain.py,
> and then encountered an error that I think is a killer...
> ImportError: No module named fcntl

FCNTL isn't available on Windows, so if sb_mboxtrain does need it then that
would be a killer.  

There is a patch (I'm not familiar with it) to get mboxtrain to work with

[ 857937 ] sb_mboxtrain was not running on windows

IMO, you'd be better off with sb_filter, anyway.

> If I could use the database created by my Outlook
> plugin then I'd be ok, but I don't think that'd work.

The token database that SpamBayes uses is the same, whichever script you're
using.  Outlook has an additional message information database which is only
for Outlook (sb_server and sb_imapfilter have a different one), but you
shouldn't need that for anything command-line based.

> sp_filter.py doesn't throw that error, but doesn't seem to 
> work quite right either.  I have a known spam on my disk
> called spam1.mai and I've tried the following:
> sb_filter.py | type spam1.mai
> Error: bsddb._db.DBNoSuchFileError: (2, 'No such file or directory')
> I'm sure it has something to do with the configuration, but I 
> don't know where to start... I've followed (I hope) all the install
> instructions.

sb_filter needs to know where the database is stored, or be told to create a
new database.  Either put the appropriate entries in the bayescustomize.ini
file, or use the -d switch to indicate where the database is (optionally
also with the -n switch to create a new database).

BTW, although the -g and -s switches are marked as experimental, I believe
that they are working.

So you could have something like:

sb_filter.py -d "C:\Documents and Settings\{username}\Application
Data\SpamBayes\default_bayes_database.db" < spam1.mai

(without the wrapping) to classify, and:

sb_filter.py -s -d "C:\Documents and Settings\{username}\Application
Data\SpamBayes\default_bayes_database.db" < spam1.mai

to train (as spam).

> Is there a step-by-step reference specifically for Windows 
> command line training and scoring?

Not to my knowledge, although I'm not that familiar with what's currently on
the wiki.

> If not I'll happily write one at the end of this tirade.

That would be great :)

=Tony Meyer

Please always include the list (spambayes at python.org) in your replies
(reply-all), and please don't send me personal mail about SpamBayes. This
way, you get everyone's help, and avoid a lack of replies when I'm busy.

More information about the Spambayes mailing list