Derek Ragona wrote:
= = I'd rather avoid poluting my script with e-mail sending code...
 
= You need to change your script to send the email itself.

Thank you, Derek, but -- as I stated already -- I wanted to see, if this can 
be avoided...

Since you posted your script, I'll comment on it. First of all, you don't need 
ksh for anything you are doing in this script. FreeBSD's /bin/sh is enough 
(we aren't Solaris :-) -- but is 9 times smaller here (amd64).

Now, instead of redirecting each line of output into MAILFILE, then mailing, 
and removing it, you should be either outputing everything directly into 
mail:

        {
                cat $REPORT_LOG_HEADER
                echo " " >> $MAILFILE
                echo " " >> $MAILFILE
                echo "<BR> <BR>" >> $MAILFILE

                ....
                cat $REPORT_LOG_FOOTER
        } | $MAIL -s "the report name" $MAILTO

or, if you want to use the temporary file, use exec to redirect into it 
_once_, instead of _on every line_:

        exec > $MAILFILE
        cat $REPORT_LOG_HEADER

        printf " \n \n<BR><BR>\n"
        $MAIL -s "the report name" $MAILTO < $MAILFILE
        $RM $MAILFILE

This may look nicer, but is not, because temporary files are nasty, and you 
need to be sure, that you remove them in case you are interrupted (trapping 
signals, etc.)

I was surprised, one can not redirect into a pipe directly. The following did 
not work, as I expected, with neither /bin/sh nor /usr/local/bin/ksh93. The 
following, I thought, would be the same as my first example, only 
nicer-looking:

        exec | $MAIL -s "the report name" $MAILTO
        cat .....

But it is not. So you have to chose from one of the first two examples. Yours,

        -mi
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to