LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Procmail: match pattern then pass to shell script (https://www.linuxquestions.org/questions/linux-software-2/procmail-match-pattern-then-pass-to-shell-script-246455/)

essdeeay 10-23-2004 04:28 PM

Procmail: match pattern then pass to shell script
 
Hello

I have a simple lookup table as follows:Using Procmail, if I receive an email for bedrock.com, 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):
Code:

#!/bin/sh
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:
Code:

:0 wc:
* ^X-Original-To:.*@bedrock.com
| ./<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 01:50 AM.