At 03:03 PM 7/14/2007, Mikhail Teterin wrote:
Hello!

I have a script launched from cron every morning, that gets certain data over
the Internet from a remote computer, compares the new data with that from the
previous day, and outputs the difference (if any).

I'm relying on the fact, that cron e-mails me the output of each job.

However, I modified the script recently to produce the output (if any) in
HTML, rather than in plain-text format.

The HTML arrives by e-mail just as well as plain text used to, but no e-mail
program will render it as such, because neither the cron(8), nor the mail(1),
which cron uses to send e-mail, creates MIME messages...

How can I force the ``Content-Type: text/html'' header without hacking cron's
sources? I'd rather avoid poluting my script with e-mail sending code...

Maybe, cron should apply file(1)-like logic to the e-mailed content?

Thanks for any hints. Yours,

You need to change your script to send the email itself. I have many scripts that email reports, legs, and html reports. To accomplish this I have my cron job run a script like this (I have simplified the script you should be able to use it as a base):

#!/usr/local/bin/ksh
# set full paths for all commands needed, and files needed

MAIL=/usr/bin/mail
MAILFILE=/tmp/mail_file
#fill in your correct email or alias you wish to use
[EMAIL PROTECTED]
RM=/bin/rm
DATE=/bin/date
AWK=/usr/bin/awk
LS=/bin/ls
GREP=/usr/bin/grep
FIND=/usr/bin/find
TODAY=`$DATE +%m-%d-%Y`
REPORT_LOG_HEADER=/usr/local/etc/report_log_header
REPORT_LOG_FOOTER=/usr/local/etc/report_log_footer

# start the mailfile with the proper header,
# in this case it is an HTML header
cat $REPORT_LOG_HEADER > $MAILFILE

#put more stuff into the report . . .
echo " " >> $MAILFILE
echo " " >> $MAILFILE
# Add any processing or log files to the middle of the mail file here
# you can even put HTML codes in here
echo "<BR> <BR>" >> $MAILFILE
echo " " >> $MAILFILE
# add the correct HTML footer
cat $REPORT_LOG_FOOTER >> $MAILFILE
# send it to yourself
$MAIL -s "the report name" $MAILTO < $MAILFILE
$RM $MAILFILE


        -Derek

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

_______________________________________________
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