Crontab not sending HTML only text
by tomanc from LinuxQuestions.org on (#6P368)
my script sends HTML format when i run from the command prompt, however, when i add to crontab it sends as text only, how to send HTML format from crontab?
here is my script
#!/bin/ksh
STATUS=`dsrutil $1 -C status`
DETAIL=`dsrutil $1 -C status -detail`
DATE=`date "+%m/%d/%y@%H:%M:%S"`
TMPFILE=`date "+%m%d%y%H%M%S"`
TMPFILE+=".repl"
TMPFILE+=.$$
HOST=erpvp1
BASENAME=`basename $1`
echo > /tmp/$TMPFILE
if [[ ${DETAIL} != "6022" ]]
then
echo "<html>" >> /tmp/$TMPFILE
echo "<strong>There are replication errors in $ENVDESC!</strong><br><br>" >> /tmp/$TMPFILE
echo "The following messages are for $HOST:<br>" >> /tmp/$TMPFILE
echo "<p class="red">" >> /tmp/$TMPFILE
echo $STATUS | awk '{print "<strong>" $0 "</strong>"}' >> /tmp/$TMPFILE
echo $STATUS | xargs -i grep {} /sx/script/ReplicationStatusCodes.txt | awk -F':' '{print " - " $2 "<br>"}' >> /tmp/$TMPFILE
echo $DETAIL | awk '{print "<strong>" $0 "</strong>"}' >> /tmp/$TMPFILE
echo $DETAIL | xargs -i grep {} /sx/script/ReplicationStatusCodes.txt | awk -F':' '{print " - " $2 "<br>"}' >> /tmp/$TMPFILE
echo "</p>" >> /tmp/$TMPFILE
echo "</html>" >> /tmp/$TMPFILE
( cat <<ENDOFMAIL; cat /tmp/$TMPFILE ) | /usr/sbin/sendmail -oi -t
From: replication_watch@spsx.com
To: charles.toman@spsx.com
Subject: $ENVDESC - $BASENAME replication messages
Content-Type: text/html
<head>
<style>
hr {
color:sienna;
}
p {
margin-left:20px;
}
body {
background-color:white;
}
.red {
color: red;
font-weight:900;
}
</style>
</head>
ENDOFMAIL
else
echo $DATE " - Replication status normal for $1." >> /tmp/replStatus.txt
fi
rm /tmp/$TMPFILE
here is my script
#!/bin/ksh
STATUS=`dsrutil $1 -C status`
DETAIL=`dsrutil $1 -C status -detail`
DATE=`date "+%m/%d/%y@%H:%M:%S"`
TMPFILE=`date "+%m%d%y%H%M%S"`
TMPFILE+=".repl"
TMPFILE+=.$$
HOST=erpvp1
BASENAME=`basename $1`
echo > /tmp/$TMPFILE
if [[ ${DETAIL} != "6022" ]]
then
echo "<html>" >> /tmp/$TMPFILE
echo "<strong>There are replication errors in $ENVDESC!</strong><br><br>" >> /tmp/$TMPFILE
echo "The following messages are for $HOST:<br>" >> /tmp/$TMPFILE
echo "<p class="red">" >> /tmp/$TMPFILE
echo $STATUS | awk '{print "<strong>" $0 "</strong>"}' >> /tmp/$TMPFILE
echo $STATUS | xargs -i grep {} /sx/script/ReplicationStatusCodes.txt | awk -F':' '{print " - " $2 "<br>"}' >> /tmp/$TMPFILE
echo $DETAIL | awk '{print "<strong>" $0 "</strong>"}' >> /tmp/$TMPFILE
echo $DETAIL | xargs -i grep {} /sx/script/ReplicationStatusCodes.txt | awk -F':' '{print " - " $2 "<br>"}' >> /tmp/$TMPFILE
echo "</p>" >> /tmp/$TMPFILE
echo "</html>" >> /tmp/$TMPFILE
( cat <<ENDOFMAIL; cat /tmp/$TMPFILE ) | /usr/sbin/sendmail -oi -t
From: replication_watch@spsx.com
To: charles.toman@spsx.com
Subject: $ENVDESC - $BASENAME replication messages
Content-Type: text/html
<head>
<style>
hr {
color:sienna;
}
p {
margin-left:20px;
}
body {
background-color:white;
}
.red {
color: red;
font-weight:900;
}
</style>
</head>
ENDOFMAIL
else
echo $DATE " - Replication status normal for $1." >> /tmp/replStatus.txt
fi
rm /tmp/$TMPFILE