[Scottish] procmail passing a certain attachment onto a program
Martin McCarthy
scottish at mailman.lug.org.uk
Tue Mar 4 20:26:01 2003
> is there a way of getting procmail to only pass on the text/xml part to the
> program pipe?
procmail doesn't grok MIME - that's not really part of its job. So you
need to either make your program MIME-aware using something like the
Mail::MIME module (that would be the better option), or you need some
external package to do the MIME decoding for you. The latter option is
unpleasant for several reasons. But here's a quick-and-dirty recipe
using the 'metamail' program to do the decoding. This is *completely*
untested. Also...
THIS IS NOT GOOD CODE!!! THIS CODE WILL EAT YOUR CHILDREN AND SCARE
YOUR HORSES!!!
METAMAIL_TMPDIR=/tmp/metamail_temp_nasty_aaargh
DUMMY=`mkdir $METAMAIL_TMPDIR 2>/dev/null`
# boat tracking
:0
* ^From.*technical@purplefinder\.com
* ^TO_xml@oytscotland\.org\.uk
{
:0c
xml
:0:
| metamail -q -r -w -x && cat $METAMAIL_TMPDIR/*.xml | ~/bin/xmldumper.pl; rm -f $METAMAIL_TMPDIR/*
}
Do note that this recipe will forcibly delete *everything* in
$METAMAIL_TMPDIR so do be careful where you point that variable or you
could have someone's eye out!
Once you've stopped barfing at the code you'll hopefully feel like doing
the decent thing and implementing something sensible using Mail::MIME
instead. :-)
M
--
Martin McCarthy /</ http://www.non-prophet.org
marty@ancient-scotland.co.uk \>\ http://www.ancient-scotland.co.uk
/</ http://www.ehabitat.demon.co.uk