spamassassin noob question

Eric "Shubes" plug at shubes.net
Mon Sep 25 10:25:59 MST 2006


Gerard J Snitselaar wrote:
> I didn't find anything online, so I guess the easiest thing
> to do is use a script to capture the output and echo it
> back into the file. It seems to work okay.
> 
> something along the lines of:
> 
> cd target-mail-dir
> 
> for i in *
> do
> 	o=`spam-cmd < "$i"`
> 	echo "$o" > "$i"
> done
> 
> cd orig-dir
> exit
> 
> Where spam-cmd is some form of spamc or spamassassin.
> 
> A bit kludgy, but allows me to go back and mark spam for
> removal from archived emails from mailing lists that I 
> subscribe to. 
> 
> PWD=`/bin/pwd`
> 
> if [[ $# -ne 1 ]];
> then
>    echo "usage: ${0} target-dir"
>    exit 1
> fi
> 
> cd ${1}
> 
> for i in *
> do
>   echo "checking ${i} ..."
>   o=`/usr/bin/spamc -u spamd < "${i}"`
>   echo "${o}" > "${i}"
> done
> 
> cd ${PWD}
> exit 0
> 

Two observations:
1) I'd put the output of the spam command to an intermediate file instead of 
an environment variable. Doing so might not be quite as fast, but it would 
not be resource constrained.
2) $PWD is a standard environment variable, so you should use some other 
name to save your previous PWD value, e.g.
PREVDIR=$PWD  # or PREVDIR=`/bin/pwd` - same result
do your stuff
cd $PREVDIR

cd $PWD
would be the same as
cd `/bin/pwd`

-- 
-Eric 'shubes'


More information about the PLUG-discuss mailing list