Lars Kellogg-Stedman <lars(_at_)bu(_dot_)edu> writes:
The recent discussion of bozo filters had me thinking about a more
general method of file-based message rejection. As it stands, all the
methods posted here rely on some form of grep to match the address
against a file.
This works fine, if the entire address is in the file, but I'm trying to
figure out how to do *substring* based matching. That is, if I have a
reject file that contains:
You're already doing substring matching. The condition of
* ? fgrep -f bozos >/dev/null 2>&1
will 'pass' iff some line in the header contains any of the strings
listed in the file bozos, one per line. If bozos contains the word
"bob" by itself on a line, and any line in the header contains the
string "bob" (possibly embeded in another word like "bobbing for
apples") then it will match. The "-f file" flag implicitly tells fgrep
to iterate over the lines in the file.
...
My question is not "how do I do this?"; it's "how do I do this
efficiently?" I could always write a shell script that would look
through each line in the reject file, and do a "echo $FROM | grep $line"
for each line in the file:
If you only want to run the grep across the From: header, then use
the "var ??" form to change what gets fed to the command condition:
BOZOFILE = $HOME/.bozo
FROM = `formail -zx From:`
:0
* FROM ?? ? fgrep -f $BOZOFILE >/dev/null 2>&1
/dev/null
And yes, that's three question marks, with space after the first 2.
Philip Guenther