Thanks Philip! It makes perfect sense.
:0 h | ( formail -r -i "From: $listreq" -A"X-Loop: $listaddr"; \ cat info/reject.attach $tmprequest \ ) | $SENDMAIL $SENDMAILFLAGS -t
Now I got an extended question: what is the best use of "cat" here? I got the " |formail .... | (cat; cat file) | $sendmail .... " recipe for this purpose a long time ago on this list and have been using that since then, although I thought the first pipe "|" and "cat" were redundent.
So a little while ago I put a question on "procmail" list asking why there are 2 "cat"s. In a reply, Volker Kuhlmann kuhlmav@elec.canterbury.ac.nz suggested to use:
... | /sbin/cat - info/accept.txt | ...
Now, among the 3 constructs:
1. | formail ....; cat file | $sendmail -t 2. | formail .... | (cat - file) | $sendmail -t 3. | formail .... | (cat; cat file) | $sendmail -t
Number "1" appear to be making the best sense. However number "2" and "3" must also had a reason to be that way (historically or associated with older versions of procmail or have something to do with the nature/version of "cat" or whatsoever).
Could someone put some lights on them?
Thanks!
Zhiliang
At 08:59 -0500 28 Sep 2000, Zhiliang Hu hu@genome.ansci.iastate.edu wrote:
- | formail ....; cat file | $sendmail -t
Only the output from cat(1) gets piped to sendmail there, the output from formail goes to STDOUT (which, inside of a procmailrc, will normally be /dev/null). It should be:
| (formail ...; cat file) | $SENDMAIL -t
- | formail .... | (cat - file) | $sendmail -t
The parentheses aren't needed here. Indeed, it will cause the unnecessary fork(2)ing of a subshell if your shell isn't smart enough to optimize it away.
- | formail .... | (cat; cat file) | $sendmail -t
This is essentially the same as 1, but with a useless use of cat(1). So I'll ignore this for the comparison.
Number "1" appear to be making the best sense. However number "2" and "3" must also had a reason to be that way (historically or associated with older versions of procmail or have something to do with the nature/version of "cat" or whatsoever).
There's a tradeoff between these two ways of doing this:
- Version 1 requires that another process (the subshell for running the parenthesized commands) be fork(2)ed. - Version 2 requires all output from formail to be run through two pipes rather than just one.
In most cases, the extra fork(2) is likely to be more of a drain than using the extra pipe, but if formail is being asked to preserve the bodies of large messages that could tip the scale in the other direction.
On the whole, I'd say that the two are pretty much equal, so which one to use is a matter of personal preference.
smartlist@lists.rwth-aachen.de