-   Linux - Software (
-   -   Procmail: match pattern then pass to shell script (

essdeeay 10-23-2004 04:28 PM

Procmail: match pattern then pass to shell script

I have a simple lookup table as follows:Using Procmail, if I receive an email for, I want to check to see if it needs redirecting based on the information in my lookup table. I'm unsure of the best method.

I tried egrep and awk but neither can accept a pattern from stdin, so I wrote a shell script (alias.bedrock is the lookup table):

awk "/$1/ {print \$2}" alias.bedrock

However, I don't know how to get procmail to pass the 'user@' portion of the address to the shell script. My recipe starts something like this:

:0 wc:
* ^X-Original-To:.*
| ./<script> (user@) alias.bedrock | $SENDMAIL

As you can see, I somehow need to capture the value of .* in the regular expression and pass it to my script.

1. Is this the best method to achieve this?
2. Is anyone able to offer some assistance please?

Many thanks,
Steve :)

mdavis 11-08-2004 02:19 PM

The value returned by a regular expression is stored in $MATCH

The value of the recipient of an email is stored in $2 The sender is stored in $1

Hope that helps

All times are GMT -5. The time now is 10:57 AM.