procmail
[Top] [All Lists]

Re: Killing countries by email

2000-01-03 04:11:57
Bill wrote,

| What I have is a series of filters that look like this:
| 
| :0
| * ^Received:.*\.cn[   ]
| {
|  LOG= "Reason: I don't know anyone in china. $N"
| 
|  :0
|  /dev/null
| }
| 
| Now, I know I can do something like:
| 
| * ^Received:.*\.\/(cn|nl|jp)[^        ][      ]

Let's insert another condition right after that one:

  * MATCH ?? ^^\/[a-z]+

| And then do
| 
| LOG= "Reason: I don't know anyone in $MATCH. $N"
| 
| Is there an easy way to find the correct country for the value in $MATCH?
| I know I can do it with something like:
| 
| COUNTRY=|`grep $MATCH list-of-countries | awk '{print $2}'`
| 
| Or use sed or perl to do the same thing.  Is there a better way to do
| this?

Egad, yes.  First, you can settle for having the abbreviation for the country
in your logfile instead of its code; second, sed or perl could do it without
the piping and the call to awk.  But here's another way within procmail:

twoletters=$MATCH # or { twoletters=$MATCH } as the action of that recipe

fpwssn="jp=Japan,nl=the Netherlands,cn=the People's Republic of China,\
 us=the Running Dog Capitalist Pig Abomination amerika, where there \
 is no justice"

 :0
 * $ fpwssn ?? $twoletters=\/[^,]+
 { placename=$MATCH }
 :0E
 { placename="wherever the heck the .$twoletters domain park is" }

 LOG="Reason: I don't know anybody in $placename.$N"

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