procmail
[Top] [All Lists]

Re: Dir insert like user+mailbox(_at_)foo

1998-02-08 11:35:57
        Author:        Chris Mason 
<cmason(_at_)ros(_dot_)res(_dot_)cmu(_dot_)edu>
        Original-Date: Sun, 08 Feb 1998 04:27:01 -0500
        Message-ID:    
<MailDrop1(_dot_)2d7j-PPC(_dot_)980208042701(_at_)guil(_dot_)res(_dot_)cmu(_dot_)edu>

I've looked around and I can't find an example of doing this.  Can
anyone point me in the right direction?

Sounds simple enough... I just threw this together, but it requires 'tr' and  
dirname, which I don't think is avoidable but would be happy to be proven  
wrong

NOTE: this version will try and make a directory that does not exist, which  
is slightly different than what you wanted.


:0
* ^(To|Cc):.*luomat\+()\/.*
{
        
                # change whatever+else to whatever/else
        MBOX=`echo ${MATCH} | tr -s '+' '/'`

        DIR=`dirname ${MBOX}`

                # if the directory doesn't exist, make it make sure
                # '-p' is supported by your 'mkdir' If it isn't,
                # get the GNU version
        :0wc
        * ! ? test -d ${DIR}
        | /usr/local/gnu/bin/mkdir -p ${DIR}
        
                # Check to make sure the directory exists
                # and if so, then use that mailbox
        :0w :
        * ? test -d ${DIR} -a ! -d ${MBOX}
        $MBOX

                # If something went wrong, drop it in the $DEFAULT
        :0e :
        $DEFAULT

}

I think that does a pretty good job of testing...

TjL


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