On Fri, 6 Aug 1999 12:07:38 +0200, "Ruud H.G. van Tol"
<rvtol(_at_)isolution(_dot_)nl> wrote:
(As you'll see, each block looks about the same,
does anyone know a looping construct to do the same,
because the number of users will grow?).
Use a preprocessor (such as the kevorkian.pl script from the FAQ,
adapt to suit your particular recipes) to automatically generate a
recipe for each user. But as you note, the Sendmail way is better.
I think I will go move to
sendmail virtuser/alias/general etc.
later this week ...
Good move.
DEFAULT=ruud(_at_)localhost
This will save all unmatched messages to a file called ruud(_at_)localhost
in whatever happens to be MAILDIR when Procmail trips over the end of
the .procmailrc, is that your intention?
(This is moot anyway, as your .procmailrc ends with a catch-all recipe
which will basically always succeed. If it fails, the error will not
necessarily be noticed by Procmail under normal circumstances anyhow.)
YYYYMMDD=`date +%Y%m%d`
(As noted on this list many a time, you can get a reasonable time
stamp chaply from the From_ line of the incoming message, although
transforming that into a string of numbers is not entirely trivial.)
#===========================================
# Auto-Reply to messages with Subject: ping
#-------------------------------------------
:0
*$ ! ^X-Loop: $MUSR(_at_)isolution\(_dot_)nl
* ^TO(postmaster|info|ping)@isolution\.nl
* ^Subject: ping$
{
:0 fh w
| $FORMAIL -rt -A"X-Loop: $MUSR(_at_)isolution(_dot_)nl"
:0 c # Record this ping request
| ( cat -; \
echo `uptime`; \
echo "$HOST User count: " `who | wc -l`; \
) | $SENDMAIL -t
:0 :
$BUDIR$MUSR.$YYYYMMDD.ping
}
I just happened to stumble over this. Here's a variation:
:0
* $ ! ^X-Loop: $MUSR(_at_)isolution\(_dot_)nl
* ^TO_(postmaster|info|ping)@isolution\.nl
* ^Subject: ping$
{
:0c
| ( formail -rt -k -"AX-Loop: $MUSR(_at_)isolution(_dot_)nl" ; \
echo "$HOST" ; \
uptime ) \
| $SENDMAIL $SENDMAILFLAGS -t
:0:
$BUDIR$MUSR.$YYYYMMDD.ping
}
Observations:
* Points for getting many "hard" things right! :-)
* ^TO_ is marginally better than ^TO if your Procmail is a recent
version.
* If you're going to keep the original body anyhow, there's no need
to run formail in a separate filtering recipe really.
* My copy of uptime already records the number of users.
* The effects of "echo `foo`" as compared to just "foo" are usually
not very desirable
Other than that, your recipes look very good.
LOCUSR=ruud
ADREXP=rvtol@(hacktic|xs4all|isolution)\.nl
:0 fh w
*$ ^TO()\/$ADREXP
| $FORMAIL -A"$XTO $LOCUSR ($MATCH)"
:0 E fh w
*$ ^Received: .*()\/for (<)$ADREXP(>)
| $FORMAIL -A"$XTO $LOCUSR ($MATCH)"
If you want to simplify this a little bit, and not use a preprocessor,
you can move out the actual recipe to an external file (say xiso.rc)
and do something like
LOCUSR=ruud ADREXP=rvtol@(hacktic|xs4all|isolution)\.nl INCLUDERC=xiso.rc
for each local user.
The "for <adrexp>" part of the Received: line will not be present if
more than one local user at the upstream got the same message (as I
imagine you have already figured out) and so this is of course not
very reliable.
/* era */
--
Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition