procmail
[Top] [All Lists]

Re: Message body, assign to a variable everything except lines starting with "content-" or "--"

2009-11-05 13:27:27
Shane,

I though you wanted something a little more generic.

If you want only the one liner that expects the 'exact' format you
specified, this is the active line in the script that I posted
previously, slightly reduced:

:0 b
MIME=|/bin/awk '/^--/{n++};n==1{print}'|/bin/sed -e '1d'|/bin/sed -e
'1,/^$/d'

On Fri, 2009-11-06 at 06:43 +1300, reti(_at_)igrin(_dot_)co(_dot_)nz wrote:
Thanks Everyone.
I tried this Charles and ended up egrep the whole email, header and body,
and the inverse/negation flag -v didn't seem to have effect either.

I have found in the past the just having :0B doesn't reliably imply I am
just parsing the body of the email. Indeed I have needed to use the
following *B to actually specifiy the body when I thought I had parsed it
in the first line.

:0B
*B ?? .*^\/([a-bd-z0-9])
{
 MIME=$MATCH
 }


So this then returns the whole email:

:0B
MIME=|egrep -v '^(--|Content-)'

Any thoughts ?

Thanks

Shane


Message: 3
Date: Thu, 05 Nov 2009 09:48:04 -0500 (EST)
From: Charles Gregory <cgregory(_at_)hwcn(_dot_)org>
To: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
Subject: Re: Message body,      assign to a variable everything except
    lines   starting with     "content-" or "--"
Message-ID: 
<alpine(_dot_)LRH(_dot_)2(_dot_)00(_dot_)0911050931380(_dot_)11523(_at_)barton(_dot_)hwcn(_dot_)org>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

On Thu, 5 Nov 2009, reti(_at_)igrin(_dot_)co(_dot_)nz wrote:
My goal is to assign to a variable (MIME), everything in the body apart
from the MIME boundary delimiters and content definitions that are
consistently returned from one mail server only.

If you are wililng to live with the possibility of losing matching
non-mime lines from the middle of the body and/or the separators between
multiple mime parts, then you could use egrep:

:0B
MIME=| /path/to/egrep -v '^(--|Content-)'

- Charles




____________________________________________________________
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
-- 
JW Simpson <john(_at_)swajime(_dot_)com>
SwaJime's Cove℠

____________________________________________________________
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