procmail
[Top] [All Lists]

Re: formail and multiple tasks

1995-10-12 10:04:40
hal(_at_)dtor(_dot_)com (Hal Wine) wrote:

At 18:11 10/7/95, Professional Software Engineering wrote:
   (currently using:  v2.92pre9 1993/11/29, which is what my ISP

You don't want to be using anything less than 3.10.  Check the nuglops
listing for where their versions live.  You have to be careful about
full paths then for both procmail *and* formail.
[snip]

Got it.  I was aware of Nuglops, but I hadn't figured that they had 
newer versions of programs the ISP provided (that is, I understood they 
had optional programs, and useful scripts).

The rest of my responses assume 3.10 or later.  They WILL NOT WORK 
with
earlier versions.

   What I'd like to do is have the following variables set:

   FROM
   TO
   PRECEDENCE (the actual precedence line, if any)
   PLIST and PBULK - LIST and BULK precedence flags
   SUBJECT

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)...

Caveat: if you do this with To:, you'll only find out who was on the
To line, not why it got to your mailbox.  (I.e., you could have been
CC'd or even BCC'd.)

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

   I wanted to use 'time' to log the amount of time it takes to
   complete a command (the results of which are send back in a
   Precedence: acknowledgement style message).  Unfortunatley,
   'time' sends its results out to stderr (diagnostic stream).  How
   can I get processing time to add to my output message?

Use a subshell and tie SDTOUT & STDERR together.  I forget the syntax
for sh, you can find it, but something like the following on your
procmail action line:
   (time cmd args) 2>&1 | $SENDMAIL.....

Bbbbrrrr.  I've been away from UNIX for a while.  When I used to use 
it, it wasn't much.  I guess I'll poke around for some manuals that 
discuss this (or mabey just write my own....)

NOTE: you shouldn't put anything like time output into a standard
header, like Precedence:.  Only values specified in RFC821 or RFC822
or their updates should go there.  As stated in the RFC's, if you have
non standard headers, they should always begin with an X-.

The time report was going to go into the BODY of the acknowledgement 
message (the whole body of which is merely a status report).  Some of 
the processes take an awful lot of time to complete.  And this time 
thing is only for cron-like processes, not regular mail handling...

   I also want to be able to process periodically to create a

For this, you need an outside source sending mail messages on a
regular basis.  And remember that when a mail message is sent has
nothing to do with when it's recieved.  After that, just call a shell
script to do all your decision making.  Something like:
:0 H
* ^From.*my_pseudo_cron_account
* ^Subject: TIME TICK
| pseudo_cron

Where "pseudo_cron" is the name of your shell script.

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).

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?

And another (long-winded thing):  The ISP I use has a packaged Windows 
app (collection of various client interfaces, FTP, Telnet, Mail, News, 
etc, etc), which supports MIME for file attachments (and 200K+ users).  
Unfortunatley, I couldn't get it to recognize the MIME format coming 
from the various tools on the server (though what it sends is 
recognized by elm).  It has to do with EXACT header layout (like 
"...:byte..." vs "...: Byte..."), and if it doesn't conform, the 
software won't "see" the attachments.  Anyway, being a programmer, I 
cranked out a simple mimecoder for my shell account which produces 
messages in the required format.  Then I ran into a different problem:

    coming out of the formail function (formail -rt for example), 
formail has already inserted a trailing blank line to separate the 
headers from the body -- which is problematic since some of what my app 
spews are additional header lines.  Lacking any interest in having a 
number of cryptic grep statements in the recipes, I produced a small 
program to fix my problem: it merely takes the input stream (usually 
piped), and only sends out the lines which are non-blank (this "eats" 
the spacer).  Problem fixed.

    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.

Thanks for the pointers so far.  They are REALLY appreciated.

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