procmail
[Top] [All Lists]

Variable assignment on filtering Body

1999-03-30 15:32:33

        I have a very simple question regarding assignment of variable after
filtering 
        some condition of mail body. I looked into "procmail FAQ"
        it lists this is one of the known bug. I found an ugly
workaround(using cat),
        appreciate if any one can provide any better idea.

        Let me elaborate the receipe and my problem.
        I want to strip first line of mail body and store it as variable and
use
        the varible at known places - say naming a file.

        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` }" #
<-------- ????
 
                      :0 fbw              # 2. Remove the line from mail
body
                   | egrep -v $SUBJ
 
              :0:                  # 3. Store in a file
                   | (formail -A"Bcc: $SUBJ" \
                   -I"To:=?iso-2022-jp?B?GyRCJDQ5WEZJJE4zJyQ1JF4kWBsoQg==?="
\
                   -I"MIME-Version: 1.0" \
 
-I"From:=?iso-2022-jp?B?GyRCJTQhPCVrJUklXiVzISYlNSVDJS8lOUVqPy4bKEI=?=" ) >>
"SUBJ"_mails
        }

        Problem appears in #1. $SUBJ comes as "".
        I tried different ways e.g. SUBJ=`head -1`, SUBJ=|`head -1`,....
etc. stil no better.
        But if I replace $SUBJ at subsequent places e.g. #2,#3 as `cat
sub_hdr`
        it works fine.

        Procmail FAQ lists this as know bug --
---------------------------------------------------------------------------
        Variable capture clobbers variable's old value 
                I.e. the following doesn't work as expected: 
                        :0
                        variable=| echo "$variable" | tr A-Z a-z
                The value of variable will be empty by the time the echo
executes. 
        " 
----------------------------------------------------------------------------
------------------------------------------
        Looking for a simple solution.
        Thanks in advance.      

apas Banerjee
(212)-357-0390
tapas(_dot_)banerjee(_at_)gs(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>