Google Answers Logo
View Question
 
Q: Procmail recipe using range of character classes ( Answered 4 out of 5 stars,   0 Comments )
Question  
Subject: Procmail recipe using range of character classes
Category: Computers > Algorithms
Asked by: fmcneely-ga
List Price: $10.00
Posted: 15 Jun 2002 19:45 PDT
Expires: 22 Jun 2002 19:45 PDT
Question ID: 27329
I'm trying to write a procmail recipe that sends email from a range of
IP addresses to a certain email box. For example:

:0 :
* ^Received.*123\.123\.123\.123
somemailbox

puts the any email who's received line contains 123.123.123.123 into
the email box somemailbox.

What if I wanted to put all email from IP number ranging from
123.123.123.123 to 223.223.223.223 into the same box. At first I
thought this was the solution:
* ^Received.*[123-223]\.[123-223]\.[123-223]\.[123-223]
but it is not.
Answer  
Subject: Re: Procmail recipe using range of character classes
Answered By: cjs2u-ga on 15 Jun 2002 20:11 PDT
Rated:4 out of 5 stars
 
Hi fmcneely,

I think the characters inside [ ] brackets can only be single numbers
to single numbers. For example, [0-9] would work but [10-11] would
not.

It works the same way with alphabetic characters. For example, to
specify A through D you'd say [A-D].  But if you wanted something like
AAA to AAB, you couldn't say [AAA-AAB].

What you are asking for requires breaking up the recipe. It will
expand to a multi-line rule.

:0:
* ^Received.*12[3-9]\.12[3-9]\.12[3-9]\.12[3-9]
* ^Received.*1[3-9][0-9]\.1[0-9][0-9]\.1[0-9][0-9]\.1[0-9][0-9]
* ^Received.*2[0-1][0-9]\.2[0-1][0-9]\.2[0-1][0-9]\.2[0-1][0-9]
* ^Received.*2[1-2][0-3]\.2[0-2][0-3]\.2[0-2][0-3]\.2[0-2][0-3]
somemailbox

I hope this works - just ask for Answer Clarification if it doesn't!

I did that from my head, BUT, you can still check this sites for some
additional hints:

Some site hosting many UNIX man pages
http://www.sunspot.noao.edu/cgi-bin-local/man-cgi?regexp+5


Google search terms:
man regexp [ ]
://www.google.com/search?hl=en&lr=&q=man+regexp+%5B+%5D


Sincerely,
CJS

Request for Answer Clarification by fmcneely-ga on 16 Jun 2002 11:06 PDT
Thanks for the response. I was afraid that this would end up being the
answer. I have to do a few dozen of these. Perhaps a solution for my
situation is to write an external program and pass it the parameters
of these IPs and have it return a pass/fail result.

I'm very pleased with your answer for it's correctness but still hope
that someone can come up with a better solution. Otherwise, I'd be
happy to award your answer the cash.

Clarification of Answer by cjs2u-ga on 16 Jun 2002 20:10 PDT
fmcneely,
A few dozen could really take some time! I'm more of a general unix
fan than a skillful programmer so I wouldn't know exactly how to begin
such a program. Hopefully someone can add comments which show how to
shorten the rule list.
Sincerely,
CJS
fmcneely-ga rated this answer:4 out of 5 stars
This answer has helped me understand very clearly.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy