procmail
[Top] [All Lists]

Re: procmail: piping into variables

1996-09-20 09:25:48
Alex Schroeder wrote:

Hello,

I want to generate a reply including a syntax checked version of the
received message body. This is what I tried (this is for testing only;
$test ist a folder with all the received mails in it; acheck ist a program
which will produce a a syntax check of the message body and eat the
message header, so that I cannot use "formail -r ... -s acheck -l"): 

:0
* ^Subject: ATLANTIS TEST TEST TEST
* !^FROM_DAEMON
{
 :0 c:
  | cat >> $test; echo "\n\nNEXT\n\n" >> $test

 :0 c
  $message=|

 :0 
  | (echo $message |\
     formail -r -A "Precedence: junk"\
                -A "X-Loop: alex(_at_)zool(_dot_)unizh(_dot_)ch");\
    (echo $message | acheck -l)\
    | $SENDMAIL -t

}

$message seems never to be set to the entire mail! I have tried only 
'message=|' but that just prints the mail to stdout. When I set the last 
recipy to "| echo $message > $test.more" I can check what $message 
contained. It was empty. $message does not appear anywhere else in my 
.procmailrc file. 

Is there a better way to achieve the desired effect? If not, how can I 
get the mail stored in $message?

How about a filter?  Then you don't need a variable to hold the body.

Untested (you can do that  :-) :

:0
* ^Subject: ATLANTIS TEST TEST TEST
* !^FROM_DAEMON
* !^X-Loop: alex(_at_)zool(_dot_)unizh(_dot_)ch # you probably want this too
{
  #replace the message body with syntax-checked version
  #leaving the headers alone
  # (if you can get acheck to not need the header, then just
  # skip the echos here.)
  :0 cbf
  | (echo "Dummy-Header: for acheck to eat" ; \
     echo "" ; \
     acheck -l)

  ... now do what you want with the new message body and old headers ...

Cheers,
Stan Ryckman (stanr(_at_)tiac(_dot_)net)

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