On 26-Apr-2007, at 09:18, Udi Mottelo wrote:
/var/log/procmail/07-04-26/logfile
The problem is that procmail couldn't create the log if
the directory doesn't exist. Instead of checking if the
directory exist every message over and over again I put
in my crontab:
there's another way to skin this cat. You write to the file, and
then create the directory and write to the file again if the first
write fails.
This is a better method anyway, because it also allows you to code a
fallback position if for some reason you can't create the folder.
For example, I have similar code for writing my list messages to
monthly mailboxes with inside a folder named for the list I am
subscribed to:
* ! LISTNAME ?? ^^^^
{
# LOG="List: $LISTNAME$NL"
:0fw
| formail -i "X-Kreme-Listname: $LISTNAME"
:0: $HOME/lock
$LISTNAME/$MYDATE.$LISTNAME
# if the action failed, probably the directory $LISTNAME does not
# exist, so create it
:0eW
{
LOG="FAILED WRITE$NL"
MAKENEWDIR=`test -d $MLDIR/$LISTNAME || mkdir -p $MLDIR/
$LISTNAME/`
}
# Now save the message again
:0a:
$LISTNAME/$MYDATE.$LISTNAME
# If we get this far, something is quite wrong.
# Still failed? Better save the message somewhere we can check it
:0
{
LOG="FAILED WRITE NEW DIRECTORY$NL"
:0: $HOME/lock
FAILED_LIST_SORT
}
}
That bit of code was a group effort on this list a few years back,
and I am sorry to say I did not note who finally came up with the
MAKENEWDIR line. 'Twasn't me. This patch of code allows me to
subscribe to a new list and have procmail do the right thing without
my making any changes to my .procmailrc or includes.
(For the record, the FIALED_LIST_SORT has never triggered)
--
When the stars threw down their spears
And watered heaven with their tears,
Did He smile his work to see?
Did He who made the Lamb make thee?
____________________________________________________________
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