Need help with -Ns retraining while loop

tallison at tacocat.net tallison at tacocat.net
Wed Feb 25 20:24:43 CET 2004


> Right now I have a cron job which basically runs the same command three
> times:
>
> /usr/bin/bogofilter -Ns < $spamfile
> /usr/bin/bogofilter -Ns < $spamfile
> /usr/bin/bogofilter -Ns < $spamfile
> echo -n > $spamfile
>
> It's just my way of guess-timating that a couple other people got the same
> spam message and I want the make sure the scores get changes by a few
> points
> at a time.
>
> Now, I rather have bogofilter tell me the return code and only to
> another -Ns for precise adjustments.  I'm not that great at shell script
> so,
> can someone help me out?  This is what I what to do:
>
> I've dragged one or more spam emails into $spamfile imap folder.  Cron
> calls
> shell script every 5 minutes which does:
> 1. Create cron lock file - so cron done run this on top itself.
> 2. Split $spamfile into individual spam files; X=1; erase $spamfile
> 2. bogofilter < $spamfileX
> 3. Check exit code, if <>0 then /usr/bin/bogofilter -Ns < $spamfileX; goto
> step 2.
> 4. erase $spamfileX, increment X; goto step 2
> 7. Erase lock.
>
> This way I'm not training some arbitrary number of times.
>

Could you try (untested)
NOTE: $L is a limit to prevent infinite looping.
L=30;
E=1;
while $E; do
   E=bogofilter -Ns < $spamfile;
   L=`expr $L - 1`;
   if [ ! $L ]; then
      exit;
   fi
done
rm $spamfile;





More information about the Bogofilter mailing list