Hello All,
I inherited maintenance of a script that uses awk on an input file (space delimited) and formats it into an html table and send out using sendmail. I know how to manipulate the print statements to add columns and rows, however that is the extent of my html knowlege. I've searched for potential solutions and haven't really found anything i could translate into applying to the logic in the script i have.
Here is the specific portion of the script that gener
ates the html table:
awk ' BEGIN {
print "From: <user@there.com> <Canary/Shorten Team: Morning Checkout>"
print "To: <user@here.com>"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: ** Canary/Shorten TEST ENV Morning Checkout **"
print "<html><body><table border=2 cellspacing=1 cellpadding=5 color=black>"
print "<tr>"
print "<font size="2" face="Calibri" color="blue">"
print "<td> </td>";
print "<td> </td>";
print "<td> </td>";
print "<td> </td>";
print "</p>"
print "</font>"
print "</tr>"
} {
print "<tr>"
print "<font size="2" face="Calibri" color="blue">"
print "<td>"$1"</td>";
print "<td>"$2"</td>";
print "<td>"$3"</td>";
print "<td>"$4"</td>";
print "</tr>"
} END {
print "</table></body></html>"
} ' ${mail_out} | /usr/sbin/sendmail -t
Example of input file.
ElasticSearch RED ACTIVE_SHARDS:174/174 ACTIVE_NODES:4/4
<url1> GREEN
<url2> RED
Canary GREEN
<urlX> GREEN
<urlY> GREEN
What i'm trying to do is 3 fold.
- 1. Change the subject so that if a variable in the code called OVERALL_STATUS is = RED, the subject would say:
[list] - ** Canary/Shorten TEST ENV Morning Checkout - RED **
- If the variable OVERALL_STATUS is = GREEN then the subject would say:
- ** Canary/Shorten TEST ENV Morning Checkout - GREEN **
[/list] - 2. If the 2nd field in the file has the text "GREEN", then change the font color to green. If the 2nd field in the file has text "RED", then change the font color to red.
- 3. Remove the column headers as we no longer use column headers for this script. I couldn't figure out how to remove them without breaking the logic. So it just prints 4 blank cells at top of table.
I have tried playing around with color just to see if i can change the background by using
<td bgcolor="#FF0000">$2</td>
and
<td bgcolor="green">$2</td>
And the color in the email received is not changed.
Any guidance would be greatly appreciated