On Thu, 22 Apr 2004 09:41:48 +0100 (BST), Philip Hazel wrote:
>> I'm using a construct something like this (one line - broken apart for
>> email) to pass the message to shell scripts:
>>
>> ${run{/path/to/script.sh \
>> ${quote:${message_headers} \
>> ${readfile{/var/spool/exim/input/${message_id}-D}}}} \
>> {$value}{run expansion failed}}
>
> ${readfile reads a file and saves the entire content in memory. It is
> intended for fishing small amounts of configuration data out of files.
> Using it to read a message will be a performance disaster for large
> messages.
>
> If you have to do this, better to pass the file name and let the script
> read it.
On Thu, 22 Apr 2004 17:15:08 +0200, Jan-Piet Mens wrote:
> That ${readfile might be quite expensive in terms of memory.
>
> You might also try something like
>
> ${run{/path/to/script.sh ${spool_directory}/input/${message_id}}}
>
> and have your script.sh process the file passed as the first
> argument.
Ok, I get the impression this is a bad idea. Haven't had any problems
with large messages (have 1.25 GB RAM), but I'll trust your judgement.
Need to pass the command I'm using (spamprobe) either the name of a
file containing the message (including headers) or the entire message
(including headers) on stdin. The "-H" spool file with the header info
contains a lot of extra data mixed with the message header lines, so
that seems to leave me with working with the ${message_headers}
expansion. Here's a different approach; does this seem more reasonable?
${run{/path/to/script.sh ${message_id} \
${quote:${message_headers}}}{$value}{expansion failed}}
The first script run (there may be other run statements referencing the
message depending on the result of the first call) contains this:
#!/bin/sh
spooldir=/opt/local/var/spool/exim/input
echo "$2" > $spooldir/$1-M
#use sed to lose the initial bare message id line in -D file
sed '1 s/.*//' $spooldir/$1-D >> $spooldir/$1-M
The subsequent scripts then need only reference the file
"message_id-M", since it now contains the complete message with correct
headers. After the scripts have all run the -M file is deleted.
Is this likely to be better or worse than my first attempt in terms of
performance?
Best Regards,
Brad