Well, you asked for comments.

/bin/sh  makes it a shell script, not a bash script.

The 1-line version (commands seperated by ; ) comes handy if you need to get several commands into one line, e.g. for
 - creating an alias
 - repeating an operation by stepping through bash history
 - cron jobs  (but know *which* shell is run by cron demon !)
 - wrappers (higher languages that make a system("cmd1 ; cmd2 ;...") call
 - anything else I forgot

I don't understand your cat vs. echo discussion? --and how that plays with the maildir system (which I don't use --I'm 'on' mbox). But in general, cat prints the 'items' in one sequence to stdout whereas echo lists them (more like 'ls' but with some differences. --just go and play with both). So if the 'item' is a sub-directory, and not a file cat presents you with binary garbage, not the files inside the directory.

To avoid a 'useless cat award' from Joseph you want to check if dspam only reads from stdin or if it has an option to take file names instead.
I don't know, but as one blogger said:
"The documentation for dspam is almost non-existant."

My 0.02 euros -- I bet when the veterans wake up you'll get more substantial feedback :-) ...................hORST


Date: Wed, 08 Mar 2006 23:29:48 -0800
From: Rob Hudson <[EMAIL PROTECTED]>
Reply-To: Eugene Unix and Gnu/Linux User Group <[email protected]>
To: Eugene Unix and Gnu/Linux User Group <[email protected]>
Subject: [Eug-lug] spam maintenance scripts

I want to:

- Get all mail reported as spam and feed it to dspam to learn as spam
- Get all mail reported as ham and feed it to dspam to learn as ham
- Purge my known spam folder of spam older than 7 days

I've been doing this manually about once every couple weeks. I figured it was time to write some scripts to do this nightly.

Here's a bash script I came up with. Before I set this loose I thought I'd ask if the syntax here looks correct. I replaced the cat $i lines with echo $i and things looked ok, but I'm used to seeing these on the command line with semicolons between each part... eg:
   for i in * ; do cat $i | dspam ... ; done

Thanks for any comments.  :)

-Rob

#!/bin/sh
SPAMDIR="/home/rob/.maildir/.zReport-Spam/cur"
HAMDIR="/home/rob/.maildir/.zReport-Ham/cur"

# Learn Spam
for i in $SPAMDIR/*
do
 cat $i | dspam --user rob --class=spam --source=error
done

# Learn Ham
for i in $HAMDIR/*
do
 cat $i | dspam --user rob --class=innocent --source=corpus
done

# Purge SPAM folder of messages older than 1 week
find ~/.maildir/.SPAM/cur -mtime +7 -exec rm {} \;
_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug

_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to