procmail
[Top] [All Lists]

Re: formail and multiple tasks

1995-10-12 11:26:05
At 08:15 10/12/95, Professional Software Engineering wrote:
Extract with recipies like:
:0
* ^Subject: \/.*
{
   SUBJECT=$MATCH
}

Question is, I can do this a bunch of times, and they won't EAT the
input message stream?  Rather, once I run a formail, the stream is
modified, right?  Unless I run the clone option (c)...

The approach above doesn't use formail, or anything else that procmail will
assume "delivers" the mail.  Therefore, the clone option isn't needed.

Understood.  I also figure that milti-line To: headers probably won't
be pulled into one string, right?

Wrong.  Procmail understands multi line headers and does the grep on the
full header.

Yes, basically the idea, but I wanted to have the "pseudo_cron" run
ANYTIME I get mail (the shell script would determine if it actually
needs to run).

Okay.  And here's a case where you need the clone option:
:0c
|pseudo_cron

Next question is, how can I make OR conditions that all use the SAME
action?  I want to be able to test for a number of variants on certain
requests, all in one block.  Surely this can be done?

Yes.  I usually use a setup like:
CASE=0
:0
* case 1 tests
{
    CASE=1
}
:0E
* case 2 tests
{
    CASE=2
}
...
:0
* !CASE ?? 0
{
    # real work, perhaps with explicite tests on CASE
}

N.B. the above test is a regexp, so if you have more than 9 cases, you'll
have to ensure that whatever test you use doesn't mess up.

   Long-winded lead-in, but the questions are:

       * is there an easier way of doing this that I just flaked on?

       * if not, does anyone have any interest in the (simple) line
         remover utility (as C source -- all like 7 lines of it)?  I
         don't do perl, and I know it could be done a dozen or more
         different ways (all of them valid).
         It struck me that if you remove the separator line, that you
         can simply 'cat' additional header lines into the stream,
         which is a LOT easier than having to give formail lots of
         options.

If I understand your need, you really just want to modify the headers.
Just use the 'h' (headers only) flag when you filter your header:

:0 hf
* whatever
| $FORMAIL -rt | cat - $HOME/newHeaders

This sends only the headers ('h' option) to first formail to play with
them.  Formail's output is the sent to cat, which replicates them, followed
by the new headers.  The result is used to replace the original headers
('f' option)

--Hal
Hal Wine <hal(_at_)dtor(_dot_)com>     voice: 510/482-0597


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