Brian <brian(_at_)hiddentower(_dot_)com> writes:
Is there a way to assign a variable so that procmail will pipe to the dmail
program?
No. Procmail doesn't expand any variables until after it decides what
type of action it is. You can sometimes cheat by having the recipe
check the variable and decide whether to do a mailbox or pipe action:
:0
* conditons go here...
* etc...
{
# If the variable ACTION starts with a '|' then treat
# the rest of it as a pipe action (*SIMPLE COMMANDS ONLY*).
# Otherwise it's a mailbox action
:0
* ACTION ?? ^^\|\/.*
| $MATCH
:0 E
$ACTION
}
That'll work for actions like
ACTION = "| /usr/local/bin/dmail +Test"
or
ACTION = "$HOME/some_mailbox"
But not for
ACTION = "| formail -rtk | $SENDMAIL -t"
because the pipe between formail and $SENDMAIL isn't recognized when it's
inside a variable expansion. You can get around that by using 'eval', but
then you *MUST* be very careful when setting the ACTION variable to delay
'internal' variable expansion (like $SENDMAIL above) till the action is
expanded by eval, preferably by using *single quotes* when setting ACTION.
To this, you would change the first recipe in the nested block above to
read:
:0
* ACTION ?? ^^\|\/.*
| eval "$MATCH" ;
and then you can set ACTION like:
ACTION = '| formail -rtk | $SENDMAIL -t'
If that's in some rcfile that going to be used *alot* then there are
ways to make it more efficient (in particular, you can suppress the
'eval' if there are no shell metacharacters).
However, to come back to original question: no, you cannot change the
'nature' of an action without changing the literal character that
starts it. That, of course, also answers your next question:
It would also help if I could assign $DEFAULT in the same way.
Sorry, can't be done right now.
Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail