procmail
[Top] [All Lists]

Re: Variable assignment on filtering Body

1999-04-01 01:10:23
On Tue, 30 Mar 1999 17:15:34 -0500, "Banerjee, Tapas" 
<Tapas(_dot_)Banerjee(_at_)gs(_dot_)com> wrote:

The recepie looks like this

:0
* ^From:(_dot_)*[david(_dot_)schuman(_at_)ny(_dot_)email(_dot_)gs(_dot_)com 
|tapas(_dot_)banerjee(_at_)ny(_dot_)email(_dot_)gs(_dot_)com ]
* !^Subject:.*RE:
* !^Subject:.*unsubscribe
{
  :0 bwc
  # 1. Strip first line assign that to SUBJ variable
  | /bin/head -1 > sub_hdr; SUBJ="${SUBJ:-`cat sub_hdr` }"

  UGH.  No need to do that.  You can Egrep using procmail in
native mode.  The next recipe shows how to pick up the 1st
line, the 2nd line, the 3rd line, etc.  Turn on VERBOSE to
see what $MATCH equals at each stage.  "^^" is a special
construct that means "the very beginning".
  - The 1st regexp picks up everything from the very
    beginning (of the body, due to the "B" flag) to the end
    of the first line of text.
  - The 2nd regexp skips everything from the very beginning
    to the end of the 1st line.  It then picks up everything
    to the end of the 2nd line.
  - The 3rd regexp skips everything from the very beginning
    to the end of the 2nd line.  It then picks up everything
    to the end of the 3rd line.

 :0B
 * ()\/^^.*$
 * ^^.*$+\/.*$
 * ^^.*$+.*$+\/.*$
 /dev/null

  If you remove the "B" flag, then procmail will go after
expanded header lines.  That is easy. (Remember that the
"1st header" is the unix "From " line without the colon).
For a real shock, check out $MATCH after each of the
following regexp lines.  They allow you to pick out the
1st, 2nd, 3rd, and 4th "Received: from" headers...
***REGARDLESS OF ANY OTHER INTERVENING HEADERS***.  You
can walk down the chain of "Received: from" headers and
do some tight spam-checking here. Note the parentheses
around ".*$" to the left of the "\/" match symbol.

 :0
 * ^^(.*$)+\/Received: f.*$
 * ^^.*$+Received: f(.*$)+\/Received: f.*$
 * ^^.*$+Received: f(.*$)+Received: f(.*$)+\/Received: f.*$
 * ^^.*$+Received: f(.*$)+Received: f(.*$)+Received: f(.*$)+\/Received: f.*$
 /dev/null

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Variable assignment on filtering Body, Walter Dnes <=