how to change color a text in HTML table through shell script
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.
CSV file contents
HB load,14-Jun-2018, success
MF load,14-Jun-2018,failure
SP load,14-Jun-2018,success
LN load,14-Jun-2018,failure
Script
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
file.html contents
<HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
<TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
<TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
<TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
<TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
</TABLE></BODY></HTML>
shell scripting
add a comment |Â
up vote
-1
down vote
favorite
Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.
CSV file contents
HB load,14-Jun-2018, success
MF load,14-Jun-2018,failure
SP load,14-Jun-2018,success
LN load,14-Jun-2018,failure
Script
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
file.html contents
<HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
<TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
<TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
<TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
<TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
</TABLE></BODY></HTML>
shell scripting
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.
CSV file contents
HB load,14-Jun-2018, success
MF load,14-Jun-2018,failure
SP load,14-Jun-2018,success
LN load,14-Jun-2018,failure
Script
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
file.html contents
<HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
<TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
<TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
<TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
<TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
</TABLE></BODY></HTML>
shell scripting
Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.
CSV file contents
HB load,14-Jun-2018, success
MF load,14-Jun-2018,failure
SP load,14-Jun-2018,success
LN load,14-Jun-2018,failure
Script
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
file.html contents
<HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
<TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
<TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
<TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
<TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
</TABLE></BODY></HTML>
shell scripting
edited Jun 26 at 6:54
SivaPrasath
3,88611737
3,88611737
asked Jun 26 at 5:29
John
23
23
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Try this,
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Try this,
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
add a comment |Â
up vote
1
down vote
Try this,
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Try this,
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
Try this,
awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
END
print "</TABLE></BODY></HTML>"
' test > file.html
sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t
answered Jun 26 at 6:20
SivaPrasath
3,88611737
3,88611737
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
add a comment |Â
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
1
1
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
Thanks SivaPrasath for all your help. It's working fine for me. :)
â John
Jun 26 at 9:13
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451911%2fhow-to-change-color-a-text-in-html-table-through-shell-script%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password