procmail
[Top] [All Lists]

Re: Determining a message's size in Procmail

2006-12-12 09:39:23
=- Ruud H.G. van Tol wrote on Tue 12.Dec'06 at 16:30:54 +0100 -=

 LOGFOLDER=...

Did you mean a filename by that "..."?

Yes.

 :0hc

I don't think that h-flag matters. Doesn't it cause an error message?

Why should it? We just want the header.

Shouldn't that be 
     :0 h :$LOGFOLDER$LOCKEXT
which can be simplified to
     :0 h :
because procmail defaults to $LOGFOLDER$LOCKEXT there? 
   | printf "\n%s\n\n" $LASTFOLDER >> $LOGFOLDER

No, because it applies to a "|" not a file. Since there is no
implicit lockfile for pipes, you have to specify one.
And as you noted yourself, $LOCKEXT is implicit.

So besides that my logic about keeping track of LASTFOLDER was
broken, the rules themselves were ok. ;)

Or capture the header contents into $MATCH and LOG that:

  :0
  * H ?? ^^\/(.*$)+
  {
    SAVELOGFILE = $LOGFILE
    LOGFILE     = $LOGFOLDER
    LOG         = "$MATCH$n$LOGFOLDER$n$n"
    LOGFILE     = $SAVELOGFILE
  }
(where $n is a newline)

Looks nice, but suffers from the same logic mistake as my idea,
because this would have to be applied _after_ the original rules
to catch LASTFOLDER, so all _real_ rules would need some "c" and
this would mess up too much.
Seems TRAP is the only way to achieve what OP wants.
Except, instead of using LOG to write immediately, we save the
content of MATCH in some tmp-VAR to be used with TRAP:

------ QUOTE BEGIN ------
TRAP='echo "$HEADER\n\n$LASTFOLDER\n"'

:0
* H ?? ^^\/(.|$)*
{ HEADER="$MATCH" }

... regular rules ...
------- QUOTE END -------

So you don't need sed anymore.

My experience is that a LOG="whatever" is never corrupted.

So you've been lucky. ;)

-- 
© Rado S. -- You must provide YOUR effort for your goal!
Even if it seems insignificant, in fact EVERY effort counts
for a shared task, at least to show your deserving attitude.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail