procmail
[Top] [All Lists]

Re: remotely add text to a file

2001-08-14 09:13:18
* David W. Tamkin <dattier(_at_)ripco(_dot_)com> [010814 09:17]:
Matt suggested to Luka,

| # add the first line from the body to spam word list
| :0b:$PMDIR/lock
| * ^From: Me <me(_at_)some\(_dot_)address>
| * ^Subject: add to spam list
| | sed -n 1p >>$PMDIR/crap-b.lst
|
| Just an idea, untested..

Looks good; I'd modify it, though, to allow more than one new address per
message and to let sed exit when the lines to be added end.

  # add lines from top of body to spam word list
  :0bi: # let procmail name the local lockfile; `i' to let sed exit early
  * ^From: Me <me(_at_)some\(_dot_)address>
  * ^Subject: add to spam list
  | sed -ne/^$/q -ep >> $PMDIR/crap-b.lst

There is a risk that someone else will fake a message from you to mess with
your word list, but you are just marking such messages and not discarding
them, so no damage could result from that.  Even so, you might want to
consider adding a password to the conditions.

I named a lock file b/c Luka has another condition that accesses the
crap-b.lst file.  I envision his .procmailrc file looking something like
this:

    :0fw:$PMDIR/lock
    * ? /bin/fgrep -i -f $PMDIR/crap-b.lst
    | formail -A "X-Spam: yes - bounced - permission denied" 
    
    :0bi:$PMDIR/lock
    * ^From: Me <me(_at_)some\(_dot_)address>
    * ^Subject: add to spam list
    | sed -ne/^$/q -ep >> $PMDIR/crap-b.lst

What if one process is reading a file another process is writing to?
Can that cause problems?  Probably something the OS handles?

-- 
- Matt Dunford <> zoot(_at_)zotikos(_dot_)com ..
-. www.zotikos.com -- o,;-
        
Painting, n.:
        The art of protecting flat surfaces from the weather, and
        exposing them to the critic.
                -- Ambrose Bierce
--
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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