On Mon, 05 May 97 09:06:01 -0500, David Gawlik/Webmaster
<ddave(_at_)ddave(_dot_)com> wrote:
wrong on this one. I'm completely baffled on how to keep three copies of a
message and have it stop on the last one.
The c flag will generate a copy. Anything that is defined as a
"delivering" recipe (i.e. putting the message in a file, a
non-filtering pipeline, or forwarding it) will consume one copy. You
start out with one copy. In order to file three copies, you need two
recipes with c flags (or one pipeline which takes care of generating
duplicates for itself as needed, but I guess you're not at that point
in Unix Shell Programming 101 just yet, and anyhow, Procmail is more
convenient to use than a bunch of shell commands because it will take
care of file locking for you and in general behave reasonably even
under rather abysmal conditions).
:0 Hf
* ^(To|Cc):.*\<joke-l\>
$HOME/mail/joke-l
The H is redundant, and the f flag will apparently be ignored. (In
principle, it could be a pretty fatal mistake.) I'd guess you really
meant to put a c flag here.
:0 H
* ^(To|Cc):.*\<joke-l\>
| formail -k -X To: -X Date: -X From: -X Subject: ; echo "--"
What is this one supposed to do? The H will be redundant, under any
circumstances; perhaps this would be the one place where you +want+ to
have an f flag? And what's the echo for? A message delimiter I'd
guess, but you'd have to make sure none of the messages contain any
embedded "--" lines then, wouldn't you? (If you preserve the From_
line then that should make an excellent delimiter because no messages
should contain a bare "From " at the beginning of a line. Remove the
colon in -XFrom to preserve both the From_ and the From: header.)
:0 Hf:
* ^(To|Cc):.*\<joke-l\>
$ARCHIVES/$DAYFILE
Again, the H is unnecessary and the f is definitely not the right
thing to have here.
:0:
* ^(To|Cc):.*\<joke-l\>
$ARCHIVES/$MONTHFILE
Additionally, the repeated check for the same header is a bit
redundant. You can probably save a few nanoseconds by using a recipe
with braces:
:0
* ^TOjoke-l\>
{
# Save a copy of the entire message to the main archive
:0c:
$HOME/mail/joke-l
# Do nasty things to the original's headers
:0fh
| formail -XFrom -XTo: -XDate: -XSubject:
# Save a copy to the daily file
:0c
$ARCHIVES/$DAYFILE
# Finally, deliver the "original" to the monthly file
:0h
$ARCHIVES/$MONTHFILE
}
I've opted for the From_ line as delimiter here. That way, the body of
the message never has to go through formail; this should save you
another ounce of resources. (It's particularly nice if you receive big
postings, but even for normal messages of only a few kilobytes, a
savings is never to be sneered at.) As another bonus, the produced
files will actually be valid mbox folders.
The ^TO macro is a magic gizmo which will match To: and Cc: and a
bunch of others. Look at the procmailrc manual page for details.
Hope this helps,
/* era */
As a side comment, I might point out that some versions of echo will
take two dashes to mean the end of options, so to actually echo two
dashes, you'd say "echo -- --". (Quoting the dashes doesn't make any
difference.)
--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r. <http://www.iki.fi/~era/>
* Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>