procmail
[Top] [All Lists]

Duplicate Homebrew Entries in Logfile

1997-03-06 09:46:11
    I am using procmail 3.10 under SunOS 4.1.4.  I had developed a
recipe for discarding specified emails and making a compact, one-line
entry in the logfile.  I wanted to add one more field to the record,
and after an inquiry on this list, I adapted a generous contribution. 
Now, however, for every entry, I am actually getting two identical
entries for every file processed, and I have not been able to determine
the cause of the duplication.  (Duplicate entries, of course, are
better than no entry.)

    The basic mail-discarding entry looks like this:

:0
* <
* <---- any conditions needed to select a piece of mail to discard
* <
{
INCLUDERC=$PMDIR/bitbucket.rc
}

    And bitbucket.rc, which is intended to be reusable, looks like
this:

# Turn on logging so we can record the action
VERBOSE=off
LOGABSTRACT=yes

THEDATE=`formail -zxDate:`  # When was it mailed?
WHOFROM=`formail -zxFrom:`  # Whom did this request come from?
THESUBJ=`formail -zxSubj:`  # What is the subject?

# Get message size (recipe from David W. Tamkin, slightly modified)
:0HBc  # note trailing period in first condition line
* 1^1 .
* 1^1 ^.*$
* -1^0
{ }
THESIZE = $=

# Log disposition; splitting "" across lines is deliberate
LOG="Discarded file: $THEDATE $WHOFROM $THESUBJ Size: $THESIZE
"

# Reset logging to what it normally is for procmail
VERBOSE=$VERBOSITY
LOGABSTRACT=$LOGGING

:0                         # Trash this piece
/dev/null


I have tinkered with this recipe, and I do not claim it is the most
efficient way to discard mail and compactly record the fact of the
discard, but it was working just fine _until_ I added the modified code
to get the message size and put it into the logging record.  That is
when the duplication started.  (Note: $VERBOSITY and $LOGGING are set
early on in .procmailrc, which calls the actual mail processing recipe
file with INCLUDERC.)

Paul                             <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key
Home Page:  http://www.access.digex.net/~pobart

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