procmail
[Top] [All Lists]

bypassing LINEBUF (Re: Hacking stdin?)

1997-05-19 10:02:00
era eriksson <reriksso(_at_)cc(_dot_)helsinki(_dot_)fi> wrote:
Robert Nicholson <steffi2(_at_)dgs(_dot_)dgsys(_dot_)com> wrote:
Do later procmail's cache the current messages headers and or body for
use anywhere in a recipe?

No, you have to do it yourself. It's easy to do, though. 

   HEADER=`sed '/^$/,$d'`
   BODY=`sed '1,/^$/d'`

Nothing inherently "wrong", but yes, it will break if LINEBUF is
exceeded. You could try to set it to something reasonably big, and/or

If it's a simply matter of getting the appropriate environment variables
filled, you can get it done without increasing LINEBUF.  The maximum
size of the environment is still a limiting factor though (i.e. as soon
as procmail execs another program the kernel might complain and refuse
to start the program in question); typical kernels today limit this at
1MB.

Try:

        :0 h
 HEADER=| cat

        :0 b
   BODY=| cat

As soon as procmail has to expand these itself, LINEBUF applies again, though.
If a shell expands it, LINEBUF is irrelevant, of course.

Another (unusual) trick to avoid tempfiles would be (but more memory
friendly than the techniques above):

mknod pipe p

And, then, in your .procmailrc:

        :0
        * condition
        {
                LOCKFILE=pipe.lock

                :0 c
                {
                        :0
                        pipe
                }

                :0
                | ( formail -r ; cat pipe ) | $SENDMAIL -t -oi

                LOCKFILE
        }

-- 
Sincerely,                                                          
srb(_at_)cuci(_dot_)nl
           Stephen R. van den Berg (AKA BuGless).

"Father's Day: Nine months before Mother's Day."