At 23:45 2008-07-21 -0400, Skip wrote:
I want to save the match from the following recipe, but this obviously
isn't working. Any ideas of a way to fix it? I know I need to use the \/
operator, but I don't know where to put it in this type of expression.
FGREP=/bin/grep
IPBLACKLIST=/home/peloruso/ipblacklist
If this is running as user peloruso, why not use:
IPBLACKLIST=$HOME/ipblacklist
Specifically, genericise the recipe. Likewise, you should probably just
set a suitable PATH, then do away with the hard paths for FORMAIL and FGREP...
FORMAIL = /usr/bin/formail
FROM=`$FORMAIL -x"From" -x"From:" -x"Reply-To:" -x"Received:"
-x"Return-Path:"`
Q: why aren't you just piping this formail operation into the fgrep
operation? Or is it that you want to capture the string in a verbose log?
:0fw:ipblacklist.lock
You're filtering, not writing to a file - is there a reason you're using a
lock here?
* ? (echo "$FROM" | $FGREP -i -f $IPBLACKLIST)
| $FORMAIL -A "X-IP-Blacklist: Mail originated from a previous source of
spam--$MATCH"
Uh, where are you capturing the MATCH ? You seem to be operation on the
belief that the fgrep output will be captured. First, the "?" operator at
the beginning of the condition line there checks the RESULT CODE. Second,
\/ is the MATCH operator, used in a condition line, like so:
* ^Subject:\/.*
would assign the content of the Subject: line to $MATCH. This is NOT for
program output.
IF you were to have anything in $MATCH when your recipe executed, it'd be
by chance of some prior recipe which had set it (due to correct use of the
match operator).
grep will not return the string which matched in the pattern file, but
rather the INPUT STRING, which in your case is one big long blob. If you
ran it through sed or a perl script to break it down into individual word
elements each on its own line, you could get a word match as the output
from grep.
If you ran your grep operation at a commandline, you'd see what grep will
return. It isn't what you want, even discounting that you're not capturing
it (which you COULD do by making the assignment like you currently grab the
formail output, then change the recipe condition to check for an EMPTY
string instead of the output of the command).
I don't recall that there's any feasable way to get grep to return the
matched line from the pattern file instead of the input string itself. For
this reason (as well as a major performance hit grep induces when doing a
large blob text match against a large pattern file), I wrote my own
purpose-written string matcher, but I've not published the source.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail