procmail
[Top] [All Lists]

Re: How to avoid Forking using c flag ?

1997-09-04 03:29:27
On Thu, 4 Sep 1997 11:33:51 +0200 (MET DST), Vincent Gillet
<Vincent(_dot_)Gillet(_at_)inria(_dot_)fr> wrote:
I use procmail to forward mails to 300 people depending on words in
subject ....

This is a classic. The classic answer is "don't do that" (in the case
where what you really want to do could more easily be accomplished by
e.g. sendmail aliases) but if you really genuinely want to forward
based on stuff in the Subject:, you could do something like this
instead:

       :0c
        * ^Subject: \[.*CDI.* .*([0-9][0-9]|FR|RP).*\].*\<(commercial)\>
        ! user1(_at_)magic(_dot_)fr
       :0c
        * ^Subject: \[.*CDI.* .*(38).*\].*\<()\>
        ! user2(_at_)xerox(_dot_)fr
       :0c
        * ^Subject: \[.*.* .*(13|83|84|30|06|05|26|69).*\].*\<()\>
        ! user3(_at_)avignon(_dot_)pacwan(_dot_)net

    :0    # I bet you really mean <(commercial)> here, not \<(commercial)\>
    * ^Subject: \[.*CDI.* .*([0-9][9-9]|FR|RO).*\].*\<(commercial)\>
    { FWD="$FWD user1(_at_)magic(_dot_)fr" }

    :0
    * ^Subject: \[.*CDI.* .*(38).*\).*\<()\>
    { FWD="$FWD user2(_at_)xerox(_dot_)fr" }

    :0
    * ^Subject: \[.*.* .*(13|83|84|30|06|05|26|69).*\].*\<()\>
    { FWD="$FWD user(_at_)avignon(_dot_)pacwan(_dot_)net" }

# ...

    :0  # Forward if FWD is set (i.e. contains at least one character)
    * FWD ?? .
    ! $FWD

One problem could be if FWD grows really big, enough so to exceed
LINEBUF, but you could always try to bump up LINEBUF if you want some
extra security against that. 

It also looks like you could preparse the Subject line, something like

    :0
    * ^Subject: \[\/[^0-9].*([0-9]+).*\].*<[^<>]+
    {
        SUBJ="$MATCH"

        :0  # Grab stuff inside <> near end of SUBJ into COMM
        * MATCH ?? <\/[^<>]+$
        { COMM=$MATCH }

        :0  # Grab number inside [] portion into NUM
        * SUBJ ?? [^0-9]\/[0-9]+.*\]
        {
            :0
            * MATCH ?? ^^\/[0-9]+
            { NUM="$MATCH" }
        }
 # ... 

and then compare the values of these variables instead. (This doesn't
really buy you anything in terms of script efficiency, but if these
Subject: lines are as regular as your examples imply, it could make
writing the scripts a lot easier, and perhaps even save you from
generating those regexes automatically.)

(build from script ... so don't fire me about "strange" regex :-)

The next one is a simple syntax error, but doesn't accomplish anything
you seem to want it to. The meaning of the braces is simply to group
several recipes on a common condition.

      :0
        * ^Subject: \[.*CDI.* .*([0-9][0-9]|FR|RP).*\].*\<(commercial)\>
        { ! user1(_at_)magic(_dot_)fr }

The correct syntax for the action line here would be either

    {
        :0
        ! user1(_at_)magic(_dot_)fr
    }

or, quite simply,

    ! user1(_at_)magic(_dot_)fr

but as you can see, it's equivalent to what you already had. 

Does somebody could gave me another solution to make it works better
(without forking).

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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