procmail
[Top] [All Lists]

Re: Command Line Args

2002-05-28 08:50:52
:0
RECIPIENT=|echo "$@"

should take all of the command-line args (in this case a recipient list)
and store them in the variable $RECIPIENT (space-seperated).  Is this
correct?  It doesn't seem to be working correctly in the script I've
written.

Your information is incorrect: $@ does not contain all of procmail's
command-line arguments, but rather a particular subset of them.  To quote
the procmailrc(5) manpage (version 3.13.1):
                                                 ...  When the -a
       or -m options are used, "$@" will expand  to  respectively
       the  specified argument (list); but only when passed as in
       the argument list to a program.

(The grammer error in the sentence (incorrect use of semicolon) has
been fixed in newer versions.)

So the next question is: how are you invoking procmail?  That is, what
is the command line used to invoke it?


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail


Right, I should have been more specific.  I am invoking it with -m,
actually as a postfix pipe transport, a la:

filter  unix    -       n       n       -       -       pipe flags=
        user=filter
        argv=/opt/procmail/procmail
        DOMAIN=${nexthop} SENDER=${sender}
        -t -m /opt/procmail/filter.rc ${recipient}

(argv and the two lines following make up the full command)

DOMAIN and SENDER get set correctly as one environment variable each.  I
would do ${recipient} the same way except that in a multiple recipient
delivery it only gets the first recipient in the set.  So, I pass
${recipient} as a command line argument which gets expanded out to as many
command line arguments as there are recipients.  Since I don't know in
advance how many recipients there will be I want to grab the $@ variable
and store the results in a single variable I can manipulate.

According to http://pm-doc.sourceforge.net/pm-tips.html in sec. 18.40 that

:0 ir
ARGS=|echo "$@"

should drop a whitespace split list of the args into $ARGS.  I try that in
my script as:

:0 ir
RECIPIENT=|echo "$@"
LOG="RECIPIENTS:        $RECIPIENT
"


The log file gives me this:

procmail: Assigning "RECIPIENT="
procmail: Executing "echo,"
procmail: Assigning "LOG=RECIPIENTS:
"
RECIPIENTS:


Which leads me to think that either postfix isn't passing the variable
correctly in the arg list or that procmail isn't working the way I
thought.  I wrote another shell script that simply prints the args to a
temp file and ran that as the pipe tranport command.  The args showed up
in it so it seems postfix is passing/expanding the recipients list
correctly.

Any ideas?

TIA,
--
Jim Raney

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