Hi,
I am running two scripts as below.
In Script 1 i am getting correct output in proper HTML format while in script 2 i am not getting output in mail and only html code is getting printed.I want to get the output of script 2.
Please guide.
1.IFILE=/home/home01/Report.csv
if [ -r $IFILE ] #Checks if file exists and readable
then
if awk -F, '{ T += $13 } END { exit(!T) }' ${IFILE}
then
awk -F, 'BEGIN{
c=split("3,4,8,9,13", col)
print "To: abc@gmail.com"
print "Subject:REPORT"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Content-Disposition: inline\n"
print "<HTML><TABLE border=1>"
print "<TH>Code1</TH><TH>Bus</TH><TH>File1</TH>"
print "<TH>Code2</TH><TH>#tra</TH><TH>"
}
NR>4 {
printf "<TR>"
for(i=1;i<=c;i++) printf "<TD>%s</TD>", $col
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
} ' ${IFILE} | sendmail -t
2.
log=/home/home01
rndt=`date +"%m%d%y%H%M%S"`
OFILE1="${log}/${rndt}.log"
echo " REPORT " >> $OFILE1
echo " " >> ${OFILE1}
echo " " >> ${OFILE1}
echo "###################################################################################################################################" >> $OFILE1
echo "Report Verification" >> $OFILE1
echo "#####################################################################################" >> $OFILE1
echo "1. Error details:" >> $OFILE1
echo "
IFILE=/home/home01/Report.csv
if [ -r $IFILE ] #Checks if file exists and readable
then
if awk -F, '{ T += $13 } END { exit(!T) }' ${IFILE}
then
result=$(awk -F, '
BEGIN{
c=split("3,4,8,9,13", col)
print "To: abc@gmail.com"
print "Subject: REPORT"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Content-Disposition: inline\n"
print "<HTML><TABLE border=1>"
print "<TH>Code1</TH><TH>Bus</TH><TH>File1</TH>"
print "<TH>Code2</TH><TH>#tra</TH><TH>"
}
NR>4 {
printf "<TR>"
for(i=1;i<=c;i++) printf "<TD>%s</TD>", $col
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
} ' ${IFILE})
echo $result >>$OFILE1
fi
fi
echo "This is an automatically generated message from Source Feed Reconciliation Job. Please do not reply." >> $OFILE1
cat $OFILE1 | mail -s "Report" abc@gmail.com