procmail
[Top] [All Lists]

Re: fileserver works, ls command does not

1996-04-02 10:26:55
Philip Guenther suggested to D. Emilio Grimaldo T.:

|     :0 fhw                    # reverse mailheader
|     | formail -rA "X-Loop: account(_at_)the(_dot_)address
| 
|     :0 h                      # is this a send file command?  Extract name
|     * ^Subject: send file \/[0-9a-z]+
|     | cat - ./$MATCH 2>&1 | $SENDMAIL -oi -t
| 
|     :0 h                      # is this a send list command?  Extract name
|     * ^Subject: send list \/[*0-9a-z]+
|     | (cat -; ls ./$MATCH) | $SENDMAIL -oi -t

One problem: if you invert the header before doing those subject header
tests, the inversion will have inserted Re: into the subject.  So the second
and third recipes in my excerpt from Philip's post will *never* match.

You don't want to test for "Re: send (list|file) etc." because incoming mail
that ORIGINALLY has that subject [including the Re:] is not a file or list
request.  I suggest something like this:

     :0
     * ^Subject: \/(send|list) [0-9a-z]+
     { 
      MAILDIR=wherever

      COMMAND=$MATCH
 
      :0fwh
      | formail -rtA"X-Loop: wherever"

      :0e
      some_error_handling

      :0
      * COMMAND ?? ^^send
      { FUNCTION=cat }
      :0E
      * COMMAND ?? ^^list
      { FUNCTION=ls }
      :0E
      some_error_handling

      :0
      * $ COMMAND ?? ^^(send|list) \/.*
      { FILE=./$MATCH }

      :0bfi
      | $FUNCTION $FILE
       :0a
       ! -t
    }

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