Linux permissions question
Chris Wilkes
cwilkes-bf at ladro.com
Thu Apr 1 20:02:11 CEST 2004
On Thu, Apr 01, 2004 at 01:41:02AM -0800, Chris Fortune wrote:
> This is not strictly a bogofilter problem, but I know there are some
> experienced *nix admins here, so.... I have bogofilter running from a
> perl cgi script with the `backtick` operator like so:
>
> $res = `bogofilter -Td/home/uzername/.bogofilter/ < $temp_file 2>&1`;
You could use the -I switch:
$res = `bogofilter -Td/home/uzername/.bogofilter/ -I $temp_file`;
> This works remarkably well when triggered from the Internet (or even
> from wget), but doesn't work at all when run from a cron job, like so:
>
> crontab entry:
> */10 * * * * perl /home/uzername/www/a.directory/launch.cgi
>
> launch.cgi:
> chdir("/home/uzername/www/a.directory");
> `perl do.many.spam.filters.pl >> /home/uzername/logs/log.txt`;
>
> results in log.txt:
> Bogofilter: sh:, 0%
Not knowing what your script looks like you might want to make it a
little more generic, like in your crontab run
/usr/bin/launch.cgi uzername
and have in the launch.cgi a way to grab the uzername and do the work.
I wrote a simple perl module to do the bogofilter command line tools for
me. The module is here:
http://ladro.com/bf/perlmodule/
and you use it like so:
use Mail::Bogofilter;
my ($homedir, $bf, $makespamdir, @files, @scores);
$homedir = "/home/cwilkes";
$bf = Mail::Bogofilter->new("$homedir/.bogofilter");
$makespamdir = "$homedir/.makespam/cur";
opendir (FOO, $makespamdir);
@files = grep { -f $_ } map { "$makespamdir/$_" } readdir FOO;
close FOO;
$bf->addEmail(@files);
@scores = $bf->getScoresInArray();
print "Current scores are @scores\n";
$bf->regAsSpam();
@scores = $bf->getScoresInArray();
print "New scores are @scores\n";
If there's any interest in it I can clean up the code a bit and put some
perldoc in there as well. Mail me offlist if you have any questions.
Chris
More information about the Bogofilter
mailing list