procmail
[Top] [All Lists]

Re: Would someone please explain the f-flag?

1996-03-24 09:27:30
dman(_at_)netcom(_dot_)com (Dallman Ross) writes:
I have looked over the man pages countelss times; but I still find
the explanation for the f-flag (paraphrasing: "cause the pipe to
act as a filter") to be just a little too terse.  :-)  Would someone
be so kind as to explain just how and when I might want to use the
f-flag?  Much appreciated.

The 'f' flag causes procmail to feed the message (or just the head or
body of the message if either 'h' or 'b' flag, respectively, is given)
as stdin into the action (which should be a '|' program action).  It
then catches the stdout of the action and uses that to replace whatever
it fed into the action (i.e., if it fed just the head, then only the
head will be replaced, leaving the body unchanged).  This allows you to
use any of the hoard of UNIX tools that follow the stdin/stdout
convention as filters through which you can stuff a message (or just
the head or body).  I have this image of procmail standing in front of
a huge shelf that holds a whole bunch of tubes with labels like "sed",
"formail", and "mimencode".  Then upon seeing something like:

:0 fbw
*       ^Content-Type: *text/plain
*       ^Content-Transfer-Encoding: *quoted-printable
| mimencode -u -q

:0 Afhw
| formail -I "Content-Transfer-Encoding: 8bit"


Upon seeing a match, procmail grabs the "mimencode -u -q" tube and rips
the message in two at the head/body boundary, then stuffs the body into
the tube, catching what comes out the other side, and patches it back
to the header.  Then it sees the second recipe, rips the message back
in two, and stuffs the header into the "formail -I...." tube.  The
output is slapped back onto the front of the body and off it goes.

Does that help explain it?  Or does it just reveal how strange I am?

Philip Guenther

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