Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-23-2004, 05:28 PM   #1
Registered: Aug 2004
Location: United Kingdom
Distribution: Debian
Posts: 88

Rep: Reputation: 15
Question 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,
Old 11-08-2004, 03:19 PM   #2
LQ Newbie
Registered: Sep 2003
Distribution: Redhat 9 & Fedora Core 2
Posts: 15

Rep: Reputation: 0
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to Delete line if pattern exists topcat Programming 22 08-23-2011 05:58 AM
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 10:24 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
PHP pass argument to shell script monzter Programming 2 08-14-2004 07:16 AM
Pattern Matching Help in Bash script cmfarley19 Programming 1 04-07-2004 10:22 AM > Forums > Linux Forums > Linux - Software

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration