procmail
[Top] [All Lists]

Re: Procmail experiments -- good methods

1999-05-16 10:14:13
Harry wrote,

P> Original headers start immediately below the ^BEGIN line but are not
P> in unix format.  The "From " line and "Return-Path" lines are missing.

P> ##Remove stuff added by archive server
P> :0fhbwc
P> * Subject: archive retrieval: latest/[0-9]+
P> | sed  -e '1,/BEGIN------------cut here-------------/d' \
P>        -e '/END--------------cut here-------------/,$d' \
P> |awk 'BEGIN {"date"|getline;print "From 
apollo-list-request(_at_)redhat(_dot_)com", $0 "\nReturn-Path: 
<apollo-list-request(_at_)redhat(_dot_)com"};{print}'

Era responded,

E> :f and :c are usually not meaningful at the same time. Take out the c
E> flag is my advice.

Additionally, `hb' is the default, so the only flags you need are fw or just
f.  Normally this would call for `b' without `f' but I see that you want to
destroy the head intentionally.

Moreover, the sed command is inefficient, because it keeps reading to the end
of the input when there is no reason to.  This is better:

   | sed  -ne '1,/BEGIN------------cut here-------------/d' \
          -e '/END--------------cut here-------------/q' -ep \

and add the `i' flag to the flag line so that procmail won't be upset when
sed quits as soon as its work is done.

Now, about replacing the original headers with a dummy that has only From_
and From:, perhaps it can be done with formail or procmail instead of date
and awk.  I need to run now, so I'll post separately about that.