procmail
[Top] [All Lists]

Re: Re^2: chmod immediately?

1997-07-16 08:15:00
Dave/WebMaster <ddave(_at_)ddave(_dot_)com> writes:
...
:0h
HEAD=|formail -X ""

:0b
BODY=|formail -I ""

No need for formail in either of those.

        :0 h
        HEAD=|cat

        :0 b
        BODY=|cat

Both HEAD and BODY can be very large, so don't expand them inside conditions,
or in action lines that aren't going to invoke the shell.


UMASK=022   # set less paranoid umask to create world readable file

:0ciw:
|echo "<!Content-Type: \"text/html\">"                 >  $WEBMAIL/$FILE;\
echo "<HTML><HEAD><TITLE>EMAIL2WEB</TITLE></HEAD>"     >> $WEBMAIL/$FILE;\
echo "<BODY BGCOLOR=\"#FFFFFF\">"                      >> $WEBMAIL/$FILE;\
echo "<H3>DANGEROUS DAVE'S<BR>"                        >> $WEBMAIL/$FILE;\
echo "EMAIL2WEB INTERFACE</H3>"                        >> $WEBMAIL/$FILE;\
echo "<PRE>"                                           >> $WEBMAIL/$FILE;\
echo "$HEAD"                                           >> $WEBMAIL/$FILE;\
echo "$BODY"                                           >> $WEBMAIL/$FILE;\
echo "</PRE>"                                          >> $WEBMAIL/$FILE;\
echo "<H3>END of MAIL2WEB</H3>"                        >> $WEBMAIL/$FILE;\
echo "</BODY></HTML>"                                  >> $WEBMAIL/$FILE;\

Hmm, looks like we can eliminate the HEAD and BODY variables:

        :0 cw : $WEBMAIL/$FILE.lock
        |(echo "<HTML><HEAD><TITLE>EMAIL2WEB</TITLE></HEAD> \
                <BODY BGCOLOR=\"#FFFFFF\"> \
                <H3>DANGEROUS DAVE'S<BR>EMAIL2WEB INTERFACE</H3><PRE>"; \
                cat -; echo "</PRE><H3>END of MAIL2WEB</H3></BODY></HTML>" \
         ) > $WEBMAIL/$FILE

(What's with the all caps text?  Do titles really look better in uppercase?)

"cat -" will output what is fed to it.  In this case, since the echos
don't read any of the message coming down the pipe from procmail, cat
will get it all.  If you do the above, you can remove the recipes that
create HEAD and BODY.

If you were feeling really orderly you could even put the HTML header
and footer into files, and then the action would just become:

        :0 cw : $WEBMAIL/$FILE.lock
        | cat $WEBMAIL/header - $WEBMAIL/footer >$WEBMAIL/$FILE

Isn't that clean looking?

Note that in both of these recipes we have to explicitly give the
locallockfile name, as there's no ">>" for procmail to pick it off of.


UMASK=077    # restore the paranoid mask


Philip Guenther

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