[Top] [All Lists]

Re: IP regex

2009-02-19 23:45:27
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:


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$ITERATION^0
        * 1^0

        EXTRACTEDIP=`sed $ITERATION!d myipfile`

        * EXTRACTEDIP ?? ^^^^
                # variable is empty - exit the rcfile (which will cause all
                # the looping to end)


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: <>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

procmail mailing list   Procmail homepage:

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