procmail
[Top] [All Lists]

Re: ".procmailrc" & "sh"

2001-06-23 22:05:06
Robert told Roy,

| Environment variables are handled *exactly* like in sh, so that means
| you can't have a variable like the one above. Because, spaces are
| bad(tm).

In sh they are, but procmail permits spaces on either side of the equal sign.
That wasn't Roy's problem.

| LOGFILE=$MAILDIR/log.`date +%y-%m-%d`  # should work just fine

And subsequently Roy has reported that it didn't.  Some things to check, Roy:

1. Is /bin/sh the value of $SHELL in your .procmailrc?
2. In your .procmailrc's $PATH, does /bin precede any other directory that
   has an executable called "date"?
3. Is your mail delivered on the same machine where you had the shell session
   from which you showed us the output of the two which commands and the date
   command?

because somehow you're getting a null substitution for `date` when procmail
tries it.  If all the answers to those questions are yeses, my only sugges-
tion is to try strong-quoting the formatting parameters; that sometimes helps
with date's percent escapes:

 LOGFILE=$MAILDIR/log.`date +'%y-%m-%d'`

Pentultimately, it's not efficient to run date for every piece of incoming
mail.  Better, you should do it once a day with cron if you can.  In your
crontab, put this:

 0 0 * * * echo LOGFILE\=\$MAILDIR/log.`/bin/date +'%y-%m-%d'` > $HOME/.plfname

and in your .procmailrc, instead of LOGFILE=anything,

 INCLUDERC=$HOME/.plfname

Finally, if you want to log mail by the date it arrived rather than the date
on which you process it, and your MTA gives you From_ lines, you can extract
the date from the From_ line within procmail and use that to determine the
name for the logfile.  I've illustrated that on this list before, so maybe
someone can dig it out of the archives while I'm asleep; if not, I'll retype
it Sunday afternoon or evening (I'm on UTC -5 [CDT] this time of year).

_______________________________________________
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>