procmail
[Top] [All Lists]

Re: remove text from body and change subject and author

2005-01-12 05:41:56
Hi,

* Dallman schrieb am 10 Jan 2005:

On Sun, Jan 09, 2005 at 02:12:30PM +0100, Fabian Braennstroem wrote:

* Michelle schrieb am 09 Jan 2005:
formail ?

Thanks! I just found a nice example to change the subject
which looks like this:

    :0hw
    SUBJECT=|formail -xSubject: | sed -e 's/\[[a-zA-Z0-9:_\. -]*\] //gi'
    
    :0 fhw
    | formail -i "Subject:$SUBJECT"
   
This works fine, but I have no clue about 'sed' so removing

Well, I'd not wish to call that a "nice example."  You certainly do
not need to pipe formail through sed and then run yet another instance
of formail to change the subject.

'OpenFoam: Running / Solving / CFD:' doesn't work with the
following:

    :0hw
    SUBJECT=|formail -xSubject: | sed -e 's OpenFoam: Running / Solving / 
CFD: //gi'

That's because, and pardon me, but you said it yourself above: you have
no clue about sed.  ;-)

I'm not trying to claim you should know about things that you don't, uh,
know about.  But I have to wonder at why you would try to just stick any
old guesswork syntax in there and even have a fifteenth-century shipmate's
hope in Hell thet you'll find dry land after the next storm.  :)

Yes your are right. I took some time to get into 'sed' and
basic searching, inserting, appending and replacing work
fine :-)


Is there somewhere a nice page with some 'formail'-examples?

Did you try "man formail"?  It does have a short Examples section.

Yes.


Anyway, Fabian: there are two things going on here.  One is getting
the present value of the Subject or From; the second is making a
substitution.  Michelle is correct that formail is a good tool here.
But the use would be better limited to replacing the old header with the
new.  We can use pure procmail easily to find the Subject and From.


1) Get the Subject:

    :0  # in brackets below is a caret, space, and tab
    * ^Subject:.*\/[^         ].*
    { SUBJECT = $MATCH }

    (Do the same thing for From:)

2) I can't remember what you want to change or eliminate in the Subject, and
I can't tell what your failed attempt at sed is indended to do; but assuming
it is to delete all instances of those words in your sed statement so you can
prepend your own thing,


  :0 fw
  * SUBJECT ()\<(OpenFoam: Running|Solving|CFD:).*\/[^        ].*
  | formail -I "Subject: Your Words (if any) $MATCH"

Thanks for the example! Somehow it does not work for me....
right now, Michelle's scenario works.

Best Greetings!
-- 
Fabian Braennstroem
Duesseldorf/Berlin

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail