procmail
[Top] [All Lists]

Re: Variable not working for two words

2002-05-24 06:28:27
On 23 May, S Semple wrote:
| Can someone tell me the right syntax for the Variable SRCH_ . I'm new at this.
| I have copied this from the newsgroups etc. and it all works fine 
| if I am only searching for one word, But is there not some way to 
| search for more than one word using the Variable SRCH_
| 
| The below recipe always finds Ebay, But I only want it to find Ebay 
| Auction. I have tried a variety of quoting mechanisms and tried to find out 
what
| works in grep etc. but I just can't seem to get it.
| 
| SUBJ_=`formail -xSubject: \
|        | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
| 
| 
| SRCH_ = Ebay Auction
| :0
| * To:.*Undisclosed.Recipients@
| 
| {
|  :0 B
|  * .*$SRCH_
| 
|    :0 fwh:
|    | formail -I"Subject: SPAM=>${SRCH_}< ${SUBJ_}"
|    :0:
|    IN-Check
| }
| 

I'm not sure what quoting methods you tried, and why they didn't work,
because the only two I can think of should've worked fine.  The line 
"SRCH_ = Ebay Auction" sets the variable "SRCH_" to "Ebay" and unsets
the variable "Auction".  The probem may also have been a missing '$' on
the condition line to tell procmail to expand the SRCH_ variable, or a
missing action line (or brace pair), but then I don't know how it
would've matched Ebay.  It's always best to look at and, if that doesn't
solve it for you, forward the relevant log entries with your question.

The formail |expand |sed pipeline is unnecessary. I also moved both the
SRCH_ and SUBJ assignments inside braces so you only set SRCH_ if
Undisclosed... matches, and only set SUBJ if SRCH_ matches. If you use
either or both of those variables in other succeeding recipes, then move
them back outside the first brace level as you had them.

  :0
  * To:.*Undisclosed.Recipients@
  {
    SRCH_ = 'Ebay Auction'
    # Note leading $ below (also, leading .* unnecessay as you used it)
    :0 B
    * $ $SRCH_
    {
      # <space> and <tab> in each [character class] below
      :0
      * ^Subject:[      ]*\/[^  ].*
      * MATCH ?? ^^\/.*[^       ]
      { SUBJ = $MATCH }

      :0 fhw
      | formail -I"Subject: SPAM=>${SRCH_}< ${SUBJ:-SUBJ unknown}"
      :0:
      IN-Check
    }
  }
  

-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


_______________________________________________
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>