procmail
[Top] [All Lists]

Re[2]: Counting hits - revisited

2004-06-06 06:49:43
On Sun, 06 Jun 2004 07:53:05 -0400 (EDT) "fleet(_at_)teachout(_dot_)org" 
<fleet(_at_)teachout(_dot_)org> wrote:

On Sun, 6 Jun 2004, Ruud H.G. van Tol wrote:

I'm glad that I don't have your mind.

Well, if you want it you can have it.  It doesn't seem to be doing *me*
any good at the moment.
 
Sounds like me right now.

Once you choose the second alternative, you need a way to get the
number of hits from the number of lines in the file. 'wc -l' can do
that for you.

Yes, of course.  But in all these methods we're still generating a call
to
the system to write to a file, right?  (Granted, we're not *reading* from
the file, so we've reduced the number of calls to the system.)

In the midst of worrying WHAT was in the files (a number counter or a bunch
of dots) you lost track of your original query. You wanted to know how to
create counter files withing procmail without shelling out to
read/increment/write the counter number each time. By using LOGFILE and LOG
you avoid a shell call.

Of course you have to make the system calls to write to the files. Somehow
I don't think there is a method available to create a counter file without
actually writing to the file <grin>.

Rough of using LOG to create your counter with dots (since you said the
actual data, other than a count, is written to message headers). I did not
"flesh this out", just skimmed 'man procmail' on using "LOG" and "LOGFILE".

LOGFILEHOLD = $LOGFILE 
#save whatever you had your original logfile set to

:0 conditions
rest of recipe

LOGFILE = /home/fleet/counterfiles/RECIPENAME.cnt  
#set logfile to the name of your recipe counter file 

LOG = . 
#add a dot to the counterfile

LOGFILE = $LOGFILEHOLD
#set logfile back to what it was before we entered this recipe 

/home/fleet/mail.box
#deliver the message (or leave the nest and continue processing) with info
#like final delivery location being written to the main logfile rather than
#your counter file. Make sure you have reset $LOGFILE before reaching this
#line. 

Gerald


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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