Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Procmail to Perl : Match subject and pass body

Status
Not open for further replies.

scottyj1

MIS
Nov 23, 2006
2
GB
Hi. I'm struggling to get procmail to forward the body of a message to my perl script.

I can match on the subject line O.K but it doesn't seem to pass the message body to the script.

My procmail recipe is :-

Code:
:0
* ^Subject:.*heartbeat.*
| ./checkmail/heart2db.pl

:0
* ^Subject:.*Daily Audit.*
{
  :0 bw
  | ./daily_audit/daily_audit.pl "$MATCH"
}


E-mails with "heartbeat" work fine but e-mails with "Daily Audit" run the script but don't pass any information to it.

I've spent weeks looking for help on this but haven't had any joy. Can someone please help ?

Thanks
 
You haven't told the regex what to match. Quoting from man procmailrc:
Code:
\/  Splits  the expression in two parts.  Everything 
    matching the right part will be assigned to the  
    MATCH  environment  variable.
So if your pattern was:
Code:
* ^Subject: \/.*Daily Audit.*
and the actual message contained:
Code:
Subject: Daily Audit for 11/28/06
then the value $MATCH would contain:
Code:
Daily Audit for 11/28/06
It depends exactly how much of the subject line you want as to where you place that \/ seperator.
 
Sorry if I didn't make myself clear. The match works O.K but I can't forward the body of the message to my script.

I suspect it's the ":0 bw" that's at fault but I can't work it out.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top