From owner-freebsd-questions@FreeBSD.ORG Sat Jul 14 22:03:17 2007 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 938F816A402 for ; Sat, 14 Jul 2007 22:03:17 +0000 (UTC) (envelope-from mi+kde@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.freebsd.org (Postfix) with ESMTP id 4503B13C4AC for ; Sat, 14 Jul 2007 22:03:17 +0000 (UTC) (envelope-from mi+kde@aldan.algebra.com) Received: from aldan.algebra.com (localhost [127.0.0.1]) by aldan.algebra.com (8.14.1/8.14.1) with ESMTP id l6EM2lmH055713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 14 Jul 2007 18:02:47 -0400 (EDT) (envelope-from mi+kde@aldan.algebra.com) Received: from localhost (localhost [[UNIX: localhost]]) by aldan.algebra.com (8.14.1/8.14.1/Submit) id l6EM2kDL055712; Sat, 14 Jul 2007 18:02:46 -0400 (EDT) (envelope-from mi+kde@aldan.algebra.com) From: Mikhail Teterin To: Derek Ragona Date: Sat, 14 Jul 2007 18:02:45 -0400 User-Agent: KMail/1.9.6 References: <200707141603.55899@aldan> <6.0.0.22.2.20070714155424.0242a958@mail.computinginnovations.com> In-Reply-To: <6.0.0.22.2.20070714155424.0242a958@mail.computinginnovations.com> X-Face: %UW#n0|w>ydeGt/b@1-.UFP=K^~-:0f#O:D7whJ5G_<5143Bb3kOIs9XpX+"V+~$adGP:J|SLieM31VIhqXeLBli" Cc: questions@freebsd.org Subject: Re: Can cron e-mail HTML? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2007 22:03:17 -0000 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 "

" >> $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

\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