procmail
[Top] [All Lists]

Re: automatically adding names to a file

1997-01-27 13:18:02
At 12:12 PM 1/27/97 -0500, Timothy J Luoma wrote:

I get email from a SPAM fighting group with the subject like this:

Subject: spam: waltercan(_at_)worldnet(_dot_)att(_dot_)net: Hello

Where the first word is "spam: " the second word is the offending  
email address, and the third word is the subject of the message that  
this offendee sent.

I would like to take the second argument (the email address) and  
REMOVE the ":" at the end of the email address and paste that to a  
file of known spammers:

I've been thinking about this:

:0
* ^From spam-list-owner(_at_)toby(_dot_)han(_dot_)de
* ^Subject: spam: \/.*$
{
      spammer=`echo $MATCH | awk '{print $1}' |tr -d ":"`
      
      
      :0hi: spamfile.lock
      * ! ? grep -s -i -w "$spammer" $PROCDIR/killfile-by-from-line
      |/bin/echo "$spammer" >> $PROCDIR/killfile-by-from-line

      :0
      |appnmail DuplicateSpam

}

The only thing I am worried about is the "tr -d" line.  Should I be  
worried about that?  is there a better way to do this?

If you're sure the "word" ends in a ":" then you can skip the
tr process altogether, using a little more of awk:

        spammer=`echo $MATCH | awk '{print substr($1,1,length($1)-1)}'`

This drops the final character from $1, whatever it is.  Should perform
better, but I don't know if it's "best"  :-)

and about the "DuplicateSpam" thing... I put that there to catch if  
I get two reports about the same guy (ie they are already in the  
killfile).  Is there another way of doing this?  I don't really care  
to see the message, I suppose I could send it to /dev/null.

If the duplicates are rare, they won't hurt performance much (the
extra checks may cost more); you might consider just running your file
through "sort -u" (while locked, of course) once in a while.

Cheers,
Stan

<Prev in Thread] Current Thread [Next in Thread>