procmail
[Top] [All Lists]

Re: Odd ball procmail usage works, mostly...

1997-06-05 12:59:00
Bill Costa - NIS/CIS - University of New Hampshire 
<Bill(_dot_)Costa(_at_)UNH(_dot_)EDU> writes:
...
   Here's what the aliasfwd ProcMail script looks like:
...
:0fb
| echo "     Your message"; \
 echo ""; \
 echo "> Subj: $SUBJECT"; \
 echo ""; \
 echo "     that was originally mailed to the old UNH address:"; \
 echo ""; \
 echo "           $OLDADDR"; \
 echo ""; \
 echo "     has been automatically fowarded to the new address:"; \
 echo ""; \
 echo "           $NEWADDR"; \
 echo ""; \
 echo "     Please make a note of this new address and use it in all"; \
 echo "     future correspondence.  Messages sent to the old address"; \
 echo "     will no longer be accepted or forwarded after $EXPIRES."; \
 echo ""; \
 echo ""; \
 echo "                                         Virtually yours,"; \
 echo "                                         The Alias Server Admin";

#---------------------------------------+
# ...and send it back.                  |
#---------------------------------------+

:0
! -oi -t

DELIVERED=yes
- - - - - - - - - - 8< - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   I have 5 different scripts that are all simple variations on this
   basic theme.  

   This mechanism has been working well for us, although every once in a
   while I'll see an error like the following in the log file:

- - - - - - - - - - 8< - - - - - - - - - - - - - - - - a log entry - - - - - -
From: mi14(_at_)cornell(_dot_)edu
 To: BOTSWANA(_at_)mathcs(_dot_)duq(_dot_)edu (destined for 
nyasanet-REQUEST(_at_)maelstrom(_dot_)stjohns
.e
du)
 On: Fri, 25 Apr 1997 22:12:50 -0400 (EDT)
Subj: CREATION OF A PAN-AFRICAN SENATE: A CALL FOR ACTION
procmail: Error while writing to " echo "     Regarding your message"; \
 echo ""; \
...
procmail: Rescue of unfiltered data succeeded
- - - - - - - - - - 8< - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   My guess is that funny characters in the $SUBJECT or other variables
   are breaking the echo command.  Or???   Any suggestions as how to fix
   this or recommendations for a better, more robust approach?


The problem has nothing to do with the expansion of $SUBJECT or
anything like that, and Timothy Luoma's suggestion to change them to
"${SUBJECT}" doesn't change anything at all (Sorry Timothy).  The real
problem is that procmail expects all actions to read their entire
stdin.  After all, how you can filter the body of a message if you
never read the body in?  Since none of the echo commands read anything,
procmail can't write the entire message down the pipe, and assumes the
action failed.  The solution is to tell procmail to ignore this
condition, by putting the 'i' flag on the recipe.

(You may wonder why it usually works.  The answer is that the kernel
buffers a certain amount of data written to pipes.  If procmail can
write the entire old message body into that buffer before the echo's
complete, then it [procmail] doesn't see any problems.  If the echo's
complete before it can do so, or if the old message body was larger
than the pipe buffer, then procmail get an error writing to the pipe
when the action finishes.)

Philip Guenther

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