procmail
[Top] [All Lists]

Re: intermittent error from echo

2000-08-31 15:53:58
Stan Ryckman wrote:
I'm puzzled by the following... is it that $MATCH contains
newlines?  ...

I don't think so.  I think it's that the echo program runs so quickly
that it sometimes terminates before procmail fills the pipe.  Thus, as 
you noted, adding the "i" flag makes the error message go away.

...
to "filter_error".  When it does, the log isn't terribly informative;
the relevant excerpt:
=====begin log excerpt=====
procmail: Match on "^Subject:.*magic"
procmail: Assigning "MATCH="
procmail: Matched "small test case

"
procmail: Match on "^^\/(.*($))+"
procmail: Executing "echo,small test case

"
procmail: Error while writing to "echo"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is, as you surmised, the critical information.

...
Adding the "i" flag results in no error message, and the whole body
goes to the "ready_for_more" file with nothing lost, all the time.
(Plus one extra newline, but that's a minor issue for another time.)
So what can the occasional error be, such that when "i" is used to
ignore it, no bytes get lost anyway (which contra-indicates the error
being an early closed pipe)?

Your recipe:

         :0abBfw
         * ^^\/(.*($))+
         | echo "$MATCH"

is saying: Push message-body into a pipe, whose other end is "echo".
The "echo" program ignores the input, and only echoes the $MATCH.
Hence, whether you get a write error on the pipe or not is only a
matter of how big the buffers are (some unix systems have 4K or 10K
bytes) and whether the "echo" program finishes execution before
procmail finishes writing into it.

Does that make sense?  It doesn't matter what happens on the pipe,
because the "echo" program will ignore the input it gets from the pipe 
anyway; the output of "echo" is just $MATCH .  If you like you might
try: 

         :0abBfw
         * ^^\/(.*($))+
         | (cat > /dev/null; echo "$MATCH")

which explicitly tosses the body before replacing it with the output
of 
    echo "$MATCH"

hth
collin
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>