At 21:52 2009-02-19 -0500, Fleet Teachout wrote:
And is they *any* way to test a regex in actual procmail format?
Grep/egrep differ enough that I'm never sure I've got it right.
Sandbox it and throw a known range of values at it.
Ok. I have had a sandbox for years; but I only know how to use 'formail
-s procmail ~/sandbox/test.rc < ~/Mail/backups/backup' I can change the
input of course; but this presumes a mail format. If I create a data file
of IP ranges, can I use procmail directly to look at that data file?
procmail isn't a pagination tool (i.e. like more or less) - you don't use
it to "look at" something.
Let's assume you're extracting an IP from a Recieved: header to check it
against a DNSBL (for which there's a documented recipe in the list
archives, BTW). Do whatever you'd be doing to get to the IP address and
store it into a variable, then have all your checking code in an
INCLUDERC'able file. Now, your checking code is separate from the actual
headers - it's just working with a variable which is supposed to contain an
IP address.
You could wrap the checking code with something that sets the variable
arbitrarily:
EXTRACTEDIP="192.168.2.1"
INCLUDERC=checkip.rc
Or you could have something that iteratively runs through some other file:
[in loop.rc]
# This little tidbit increments the iteration counter
# prefixing the iteration variable with 0 ensures that if it is unset
# that it'll evaluate as 0. The leading 0 has no effect otherwise.
:0
* $ 0$ITERATION^0
* 1^0
{
ITERATION=$=
}
EXTRACTEDIP=`sed $ITERATION!d myipfile`
:0
* EXTRACTEDIP ?? ^^^^
{
# variable is empty - exit the rcfile (which will cause all
# the looping to end)
SWITCHRC=
}
INCLUDERC=checkip.rc
INCLUDERC=loop.rc
Then, in an external file, you could have some massive list of IP
addresses, be they generated or manually created on your part. Presumably,
you'd have some LOG constructs in your actual rcfiles, so you could log the
results of the recipes.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail