LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-23-2004, 04:28 PM   #1
essdeeay
Member
 
Registered: Aug 2004
Location: United Kingdom
Distribution: Gentoo, FC5
Posts: 87

Rep: Reputation: 15
Question 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
 
Old 11-08-2004, 02:19 PM   #2
mdavis
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
 
  


Reply


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 04:58 AM
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 09:24 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 06:17 AM
PHP pass argument to shell script monzter Programming 2 08-14-2004 06:16 AM
Pattern Matching Help in Bash script cmfarley19 Programming 1 04-07-2004 09:22 AM


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

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