HTML color code and tabluar issue

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers HTML color code and tabluar issue
# 1  
Old 11-20-2016
HTML color code and tabluar issue

input data in a file
Code:
servic webservice.somthing 200 OK
servic1 webservice.somthing 200 OK
servic1 webservice.somthing 400 BAD REQEST

Below script is making tabular form perfectly. but there are two thing i am not able to achive
1.how can i color the complete row as red when it see '400' in the row, eg line 3rd from the file.
2 BAD REQUEST have space in between, and because of that BAD is coming in one column and REQUEST is coming in another, how can i get this BAD REQUEST in one column

Code:
echo "<br />"  > output.html
echo "<html>" >> output.html
echo "<Body>" >> output.html
nawk 'BEGIN{print "<table border="1">"} 
          {print "<tr>";
                  for(i=1;i<=NF;i++)print "<td>" $i"</td>";
                  print "</tr>"} END{print "</table>"}' output.txt  >> output.html
echo "</Body>" >> output.html
echo "</html>" >> output.html
echo "<br />"  >> output.html

# 2  
Old 11-20-2016
1. Is it always the same field that needs to be checked (here: field 3)? Then you might try
Code:
awk '
BEGIN   {print "<br />\n<html>\n<Body>\n<table border=\"1\">"
        }
        {if ($3+0 >= 400) print "<tr style=\"color:red\">"
         else print "<tr>"
         for(i=1;i<=NF;i++)print "<td>" $i "</td>";
         print "</style /tr>"
        }
END     {print "</table>\n</Body>\n</html>\n<br />"
        }
' file >output.html

2. If the line's field separator is the same as the space between the two words, you're out of luck - there's no means to tell between the two. Make sure the producing command/programme/application uses a diferent FS, e.g. a <TAB> char.
Unless the field count is known and fix - then you could count the fields and add any surplus to the status field.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 11-20-2016
Yes it is the same field that need to be checked. i mean all the lines should come in out put, but the line have 400 in it should be highlighted in red

and wont we have any alternative to fix the space issue.
like if i capture all the four parameters in variable and then can i pass all those variable in such HTML code to achive it?
# 4  
Old 11-20-2016
How do you want to make ANYTHING that reads those lines, be it (shell) read, awk, any text utility, ..., tell the difference between the last and the before last space?
# 5  
Old 11-20-2016
Dear Rudic,
I am not sure how we can do it, but using sed can I omit this space between BAD and REQUEST.
then i will omit the space and take the data in other file and run HTML script on that
# 6  
Old 11-20-2016
If you say there's ONLY those two words possible - NO OTHER multi word status could come up - then of course you can do it in any tool, sed as well as awk as well as ...
Try sub (/BAD REQUEST/, "BAD_REQUEST") in above proposal.

What if e.g. FAILURE IN QUERY would be produced?
# 7  
Old 11-20-2016
The data in file is limited, either it is ok or bad request.
and how can I use sub (/BAD REQUEST/, "BAD_REQUEST")
you mean I have to use it in HTML code or separately on the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cell color based on Status in HTML output

Hi, I need to get the Status Column in Green if it is approved and Red if it is declined in the HTML output attachment#!/bin/bash body_csv="/authlistener/ProdA/service/queryRS.csv" body_html="/authlistener/ProdA/service/queryRS.html" ... (1 Reply)
Discussion started by: maddelav
1 Replies

2. Shell Programming and Scripting

Add Color To html Doc

I have a script which converts a .csv file to html nicely. Trying to add 3 colors, green, yellow and red to the output depending upon the values in the cells. Tried some printf command but just can't seem to get any where. Any ideas would be appreciated. nawk 'BEGIN{ FS="," print ... (7 Replies)
Discussion started by: jimmyf
7 Replies

3. Shell Programming and Scripting

Issue to attachment with HTML body

HI Team, I used below code to get attachment with HTML body. i having21062013.csv file . but i am getting junk .csv file. Can you please help me out. export MAILTO=rp908@gmail.com.com export SUBJECT="Test Waiver Code email" export BODY=test.html export ATTACH=21062013.csv... (4 Replies)
Discussion started by: Jewel
4 Replies

4. Shell Programming and Scripting

Handle color code

p1=text1 p2=text2(in red color) when i am trying to replace $p1 with $p2, content of the file from text2 become red. so when i open that file using vi its showing color code before tex2. please suggest me how to omit that color code and make content of that file in default color? (1 Reply)
Discussion started by: Biplab
1 Replies

5. UNIX for Dummies Questions & Answers

Color code my vi

i am running under ssh i want to know how to make vi color code my bash scripting like how do i setup vim in ssh (1 Reply)
Discussion started by: jafa401
1 Replies

6. Solaris

Color issue

On most of my Sun Blade 100 and Ultra 5 systems running Solaris 9, I am having a problem with my video. The CDE looks fine but as soon as I open up Netscape 7 everything except the browser window changes to very bright and ugly colors. This is happening on multiple freshly installed systems w/... (1 Reply)
Discussion started by: meyersp
1 Replies
Login or Register to Ask a Question