procmail
[Top] [All Lists]

Re: exporting header variables

2000-11-06 18:12:35
Joel Dudley wrote:
ffrom mail going to a specified user on my system.  I then want to export
those variables to another script that I wrote (as $SUBJECT and $TO).  ...

:0
SUBJECT=`formail -xSubject:`
TO='formail -xTo:`
| /home/user/script

Here's what I'd do.  (It's untested.)

    # Don't forget to set shell...
    SHELL=/bin/sh

    :0hi
    SUBJECT=| formail -xSubject:

    :0hi
    TO=| formail -xTo:

    # save shellmetas
    Oldmetas=$SHELLMETAS

    SHELLMETAS==
    :0
    | SUBJECT="$SUBJECT" TO="$TO" /home/user/script

    # restore shellmetas
    SHELLMETAS=$Oldmetas

Procmail will pipe only the message header to formail when assigning
$SUBJECT or $TO when it's coded as above.

The SHELLMETAS business is to force a shell to be executed, which will 
export $SUBJECT and $TO when executing /home/user/script .

After executing /home/user/script, we want to restore SHELLMETAS so
that a shell will be invoked when & only when needed....  Oh, that
won't be necessary unless you add a 'c' flag on the last ':0' line
above.  

More details on SHELLMETAS in the procmailrc manpage.

hth
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.
_______________________________________________
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>