procmail
[Top] [All Lists]

Re: [procmail] no sorting suddenly

1999-05-03 07:22:22
On 29 Apr 1999 12:49:03 -0700, Harry Putnam <reader(_at_)newsguy(_dot_)com>
wrote:
<...>
        :0
        * ^Message\-ID: *\/[^ ].*
        { MSID=$MATCH }
# original seperators were (:) colons.  changed to ** [hp]
        :0h: $SPAM_LOG$LOCKEXT
        | (echo "`date` ** $FROM_ADDR ** $TO_ADDR ** $SUBJ ** $MSID" >> 
$SPAM_LOG)
}
<...>
I'm using "awk" commands to read this file in more presentable manner,
like each $VAR on its own line, Message-id only or subject only etc.
But I suspect I could arrange  spam.rc in such a way as to do that
without "awk"  if I knew more about the syntax involved.

There's not much "syntax" involved. Whatever you manage to produce in
a normal Bourne shell script goes after the | and that's pretty much
it.

Incidentally, the parentheses are not necessary for anything ... nor
the echo, actually, if your version of date isn't picky about how long
an argument string it will accept (perhaps you should upgrade to GNU
date in that case):

    NL="
"
    :0hi:
    | date +"%c ** $FROM_ADDR ** $TO_ADDR ** $SUBJ ** $MSID$NL" >>$SPAM_LOG

See the FAQ (look for "poland") for why the :i flag is good to have
here. <http://www.iki.fi/era/procmail/mini-faq.html>

Procmail is able to deduce what lock file to use for the log file so
you shouldn't need to explicitly list that either.

(I don't think things will break if e.g. SUBJ contains double quotes
but I'm too lazy to check that.)

Possibly a better solution to all this is to simply assign to LOG the
extra information you want and then process that in awk. (You might
use newline as a field separator, that way newline is the only
character you need to be careful with ... and e.g. the date stamp and
subject will already be logged automatically by Procmail.)

One thing that clutters up spam.log is those jerky messages with
dozens of addresses in the "To:" field. How might I limit the $To
var to the match only?

What exactly do you mean by "the match"? You could trim off addresses
which are evidently not yours, but probably what you would really like
to see is the envelope recipient data, which is probably not available
(unless your ISP has special arrangements for this).

I'd also  like to get  each VAR  entry on a separate line.  Easily
done with awk but howso with the spam.rc file syntax? Tried adding
newline symbols like so:  $SUBJ\n  etc. but only succeeded in getting
the subject with "\n" (literally) after it.

The NL variable (above) is for that. (It's in the FAQ, too.) In other
words, you can put literal newlines between double quotes, but
Procmail's parsing of action lines is kind of screwy when it comes to
that, so it makes sense to declare a variable whose contents are just
a single newline, and then use $NL (or whatever you call the variable)
where you want a newline in the log file, in an action, etc.

Another thing that might be useful would  be to make the entries to
spam.log appear on the screen too.  I would get a quick look at what
went in the hole.

Various issues arise: What should Procmail do when you're not logged
in, or when you're using a program which doesn't allow you to easily
redraw the screen if it becomes messed up by Procmail's notices? You
can probably come up with good answers to this, but what I'd like to
suggest is go with the normal logging (to Procmail's default log file,
or to some other file somewhere if that suits you) and simply run tail
-f on that file while you're logged in (I often run something like
xterm -e tail -n 0 -f $HOME/Mail/procmail.log & when I log in if I'm
on an X terminal and expect to be spending more than just a few
minutes logged in. You can put that in your .profile or .xsession or
similar if you always want it started when you log in).

Being a newby with scripts and most other unix tools, I'm having
trouble catching on to the different syntaxs used in different
programs.

I have some good news: Procmail will make a lot of sense when you
learn the Bourne shell's syntax.

Hope this helps,

/* era */

.obPeeve: Check out the spelling of "separate", "separator" etc.

-- 
.obBotBait: It shouldn't even matter whether     <http://www.iki.fi/era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>
 * Sign the European spam petition! <http://www.politik-digital.de/spam/en/> *

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [procmail] no sorting suddenly, era eriksson <=