On Sat, Jan 24, 2009 at 09:52:56AM +0100, Xavier Maillard wrote:
I am trying to have a "general" recipe to do something based on
the X-BeenThere header.
Say I have a header like this one:
X-BeenThere: lolica(_at_)lolica(_dot_)org
I want procmail to "automagically" store any messages to this
list into list.org.lolica.lolica
Untested, but something like this should work.
LISTNAME=`formail -x X-BeenThere | awk listname.awk`
:0:
* ^X-BeenThere: .*
$LISTNAME
listname.awk is attached below.
Ed
#!/usr/bin/awk
# Input: a string formatted like an email address on standard input
# Output: the address segments reversed, dot separated, with '.lists' appended
# Example: "procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE" becomes
"DE.RWTH-Aachen.lists.procmail.lists"
# Example Use: formail -x X-BeenThere | awk listname.awk
# split each line on at-symbol and dot
BEGIN {
FS="[(_at_)(_dot_)]";
}
{
# iterate over fields in reverse order
for (i=NF; i>0; i--) {
# remove whitespace
gsub(/[[:space:]]*/,"",$i);
# print field with trailing dot
printf("%s.",$i);
# append "lists" after last field
if(i == NR) printf("lists");
}
}
signature.txt
Description: Digital signature
____________________________________________________________
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