procmail
[Top] [All Lists]

Re: Recipe for sending to different users round-robin

1997-06-18 11:02:00
At 08:47 AM 6/18/97 -0700, Roger Smith wrote:
I posted this in a newsgroup but I thought I would try it here also...

I would like to get a procmail recipe to forward inbound e-mail to 2
different moderators on a round-robin basis, or random basis.  What
would be a good recipe to use?  I have looked at examples and others
and cannot make head nor tail on how to alternate addresses like this.

Untested, and off the top of my head, but something like this (but
probably not exactly this; see below):

:0:moderator.lock
{
    :0
    { MODERATOR=`cat moderator.next` }
    :0ich
    MODERATOR ?? ^^fred^^
    | echo joe > moderator.next
    :0E
    {
        :0
        { MODERATOR=joe }   # in case moderator.next damaged or non-existent
        :0ich
        | echo fred > moderator.next
    }
}
# here, $MODERATOR should alternate between joe and fred

I'm not quite sure how to properly lock this, though, given the man
page entry under "BUGS":
        A locallockfile on the recipe that marks the start of a
        non-forking nested block does not work as expected.

Anyone know a way to lock a file, read it, test the contents, and
rewrite it safely (i.e., the three actions should be atomic)
without resorting to an external shell script which does its
own locking?

Cheers,
Stan

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