procmail
[Top] [All Lists]

Re: truncating body of long msg

1999-07-03 08:26:08
Volker Kuhlmann wrote,

| I am saving a copy of incoming msgs in another mailbox just to be sure. To
| save this from bombing out the quota, I'd like to truncate the body of
| large msgs to a few lines (these usually contain more or less useless
| attachments). My recipe however does not ... truncate the body
| (it works for the header, i.e. replacing b with h):
| 
| :0 c
| {
|   :0:
|   * < 204800
|   mbox
| 
|   :0 Efbw

Add the `i' flag there.

|   | head -5
|   :0 A:
|   mbox2      # this always saves the full body :-(
| }
| 
| What am I doing wrong? There must be a trick to it? Even the latest
| 3.13.1 doesn't work any different.

You're leaving the `i' flag off the filter recipe.  Because head exits
without reading the entire input, procmail senses a write error when it
tries to keep feeding text to head but head won't accept it.  However,
when you filter the headers, and head (the utility) stops reading after
five lines, the rest of the headers probably don't carry enough text to
fill more than one buffer, so procmail doesn't notice that the first buffer
doesn't empty out.

The `w' flag on a filtering recipe makes procmail recover the original text
when the filter seems to fail, and there should be a logfile entry telling
you about the recovery.  So you get the whole body back.

Suggestion, then: keep the `w' for the times when head doesn't work, but
add `i'.

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