procmail
[Top] [All Lists]

Re: remotely add text to a file

2001-08-14 09:05:36
* Odhiambo Washington <wash(_at_)wananchi(_dot_)com> [010814 10:22]:

Hi Matt,

It's me again - the Kenyan bug ;-)

I saw this and went ahead to test it but it ends up creating a file called
$ which apparently takes all newly incoming mail.

Here is what I tested:

# add the first line from the body to spam word list
:0b:$PMDIR.lock
* ^From: $LOGNAME
* ^Subject: weird-add
| sed -n 1p >> $PMDIR/.weird

I am not familiar with sed (still pleading with 'boss' to buy Unix Power
Tools) but I was looking at this as a good idea that I can use in a global
procmailrc (with a few tweaks) to enable my users here to add/remove a
.forward in their $HOME which contains an alternate e-mail address which
they want e-mails forwarded to. Then later they can send an e-mail with
the subject weird-remove and the sed portion copies /dev/null to the
.forward , nice idea?? The only hitch here is that it's not creating the
file .weird but just puts the e-mail in $DEFAULT.

May you be willing to make another 'untested one' that creates the
file? ;-)

Your recipe won't work b/c you didn't tell procmail that there is a
variable to expand in your first condition.  Perhaps rewrite your recipe
like this:

# the first '$' tells procmail to expand vars
:0bi:
* $ ^From: $LOGNAME
*   ^Subject: weird-add
| sed -ne/^$/q -ep >> $PMDIR/.weird

I'm using the sed command that David Tamkin posted not too long ago.
Why limit yourself to one line? ;)

Here's some links that have to do w/ sed:
http://www.student.northpark.edu/pemente/sed/index.htm
http://www.pegasus.rutgers.edu/~elflord/unix/sed.html
http://www.math.fu-berlin.de/~guckes/sed/

Hopefully, it will tide you over until your book arrives. =)
It's definately worth learning.  Personally, I learned sed by reading
O'Reilly's "Sed & Awk" - http://www.oreilly.com/catalog/sed2/

-- 
- Matt Dunford <> zoot(_at_)zotikos(_dot_)com ..
-. www.zotikos.com -- o,;-
        
Today's `fortune`:
If Patrick Henry thought that taxation without representation was bad,
he should see how bad it is with representation.
--
_______________________________________________
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>