procmail
[Top] [All Lists]

Re: Maintaining variables across forked procmails

1996-01-01 13:10:00
Michael Handler asked,

| I do several nested blocks with the 'c' flag -- the mail may trip one
| or more of the blocks. What I want to do is to this: if _all_ of the
| processing [recipes] fail, I want a copy of the mail saved to my
| mailbox. However, if the mail falls through to the end, and it has
| already been processed by one or more of the [recipes], I want it
| deleted. I've gotten this far:

[original code from Michael deleted]

| The problem is that the processing recipies set PROCESSED to TRUE, but
| they're clones of procmail invoked by the 'c' flag. So, the master
| copy of procmail, which processes the recipie that checks for the
| PROCESSED flag, never gets its copy of PROCESSED set to TRUE.

Exactly.

| Any suggestions on how I could rewrite this so that I can perform that
| kind of checking?

I think that, since you're not doing that much inside the inner braces, you
could get around it for your particular situation by simply using the `A'
flag instead of forking clones.  That way there will be only one procmail
process and it will get all the variable assignments. There is another way
for cases where that isn't possible, but first consider this:

  :0
  * ^TO(sub-rosa\.com)
  * ^Received: from .*c2\.org .*by .*netaxs\.com
  * ! ^X-Loop: grendel(_at_)netaxs(_dot_)com
  {
      PROCESSED = FALSE
      VALIDUSERS = 
(h[ae]ndl[ae]r|gr[ae]nd[ae]l|postmaster|root|admin|usenet|mike|anonymous|da?emon)
      OLDMAILDIR="$MAILDIR"
      MAILDIR=$HOME/erotica # since you call files in there so often

      :0
      * ^TOerotica-faq(_at_)sub-rosa\(_dot_)com
      * ! ^FROM_DAEMON
      { PROCESSED = TRUE }

          :0Ac:erotica-faq.log.lock
          | echo "`date` :$FROM" >> faq/erotica-faq.log

          :0A
          | auto-reply faq/FAQ.automail

      :0
      * ^TOerotica(-request)?(_at_)sub-rosa\(_dot_)com
      { PROCESSED = TRUE }

          :0Ac
          * ^TOerotica(_at_)sub-rosa\(_dot_)com
          | auto-reply automail/auto-ack

          :0A: # `A' refers two recipes back to where there was no `A' or `a'
          mailbox

      :0
      * ^TO(lamotte|ava)@sub-rosa\.com
      { PROCESSED = TRUE }

          :0A
          ! -oi lamotte(_at_)netaxs(_dot_)com

# By the way, you might not need the -oi any longer.  In version 3.11 (at
# least pre3 and pre4), if $SENDMAIL ends in "sendmail" then "!" implies
# -oi.  In order NOT to have -oi in effect, use "| $SENDMAIL" instead of "!".

      :0
      * $ ^TOhillary(_at_)sub-rosa\(_dot_)com
      { PROCESSED = TRUE }

          :0A
          ! -oi hillary(_at_)misty(_dot_)com

# Are you sure you want a space in the next recipe's condition?

      :0
      * $ ^TO $VALIDUSERS
      { PROCESSED = TRUE }

          :0A:
          $ORGMAIL

      :0:
      * PROCESSED ?? FALSE
      $ORGMAIL

      :0h
      /dev/null

  # Just in case anything escapes even that,
      MAILDIR="$OLDMAILDIR"
  }

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