Output as a html file


 
Thread Tools Search this Thread
# 1  
Output as a html file

Hi

i want to store output in html file.but the problem is the html file already has its content..i want to append the new output to that html file..please suggest any new ideas...i m tryin to store the output in a textfile and append to that html file..but its nt workin..need ur help
Code:
while read LINE
 do
      echo $LINE | grep UCM | egrep '(Shutdown|Unavailable)'| tee HC_Report.txt
 done <output.log

# 2  
Can you elaborate the issues you are facing when you append the text file to html file? Is it something to do with HTML tags or anything else? Be more specific about your issue.
# 3  
wen i execute this, the output of the above command is appending to column of already existing table....
# 4  
navsan, we don't have any idea what data you have in those files: output.log and HC_Report.txt, how do you expect us to provide any assistance! Post some representative samples of input & output required in code tags
# 5  
Required output
HTML Code:
<table style="background-color:lightblue;">
<tr style="background-color:blue;color:white;">
<th>Component</th><th>Status</th>
</tr>
<tr>
<td>UCM OBj MGR</td><td style="background-color:lightgreen;">Green</td>
</tr>
<tr>
<td>SR Broker</td><td style="background-color:Red;">Red</td>
</tr>
</table>
<p>failed:</p>
<p>PRDU UCM Object code app UCM  <b>Shutdown</b> Auto 0 20 1 1 2012-12-06 01:10:45 </p>
this wat i get:
HTML Code:
<table style="background-color:lightblue;">
<tr style="background-color:blue;color:white;">
<th>Component</th><th>Status</th>
</tr>
<tr>
<td>UCM OBj MGR</td><td style="background-color:lightgreen;">Green</td>
</tr>
<tr>
<td>SR Broker</td><td style="background-color:Red;">RedPRDU UCM Object code app UCM  <b>Shutdown</b> Auto 0 20 1 1 2012-12-06 01:10:45</td>
</tr>
</table>
ORIGINAL CODE
Code:
UCM=`cat output.log |grep UCM | egrep '(Running|Online)'|wc -l`
SRB=`cat output.log |grep SRB | egrep '(Running|Online)'|wc -l`

echo "<table border="2">"
echo "<tr>"
echo "<th>Component</th><th>Status</th>"
echo "</tr>"
if [ $UCM -eq 4 ]

then
     echo "<tr>"
     echo "<td>UCM</td>"
	 echo "<td style="background-color:lightgreen">GREEN</td>" 
	 echo "</tr>" 
else
     echo "<tr>"
     echo "<td>UCM</td>"
	 echo "<td style="background-color:Red"> Red </td>"
     echo "</tr>"
fi

if [ $SRB -eq 15 ]

then 
     echo "<tr>"
     echo "<td>SRB</td>"
	 echo "<td style="background-color:lightgreen">GREEN</td>" 
	 echo "</tr>" 
     
else
     echo "<tr>"
     echo "<td>SRB</td>"
	 echo "<td style="background-color:Red"> RED </td>"
     echo "</tr>"
	 echo "</table>"
	 
fi


while read LINE
 do
      echo $LINE | grep UCM | egrep '(Shutdown|Unavailable)'| tee HC_Report.txt
 done <output.log
	


cat - color.html <<HERE | /usr/lib/sendmail -oi -t
From: HC@admin.com
To:xyz@gmail.com
Cc:abc@gmail.com
Subject: HEALTH CHECK REPORT
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
HERE


Last edited by navsan; 12-09-2012 at 03:02 AM..
# 6  
Before appending text file to html file make sure you close the table tag:-
Code:
{
 echo "</td></tr></table>"
 echo "<p>failed:</p>"
 echo "<p>"
 cat HC_Report.txt
 echo "</p>"
} >> color.html

---------- Post updated at 00:36 ---------- Previous update was at 00:20 ----------

Or remove the following table closing tag from if else construct and put it outside the condition, because the table has to be closed anyway:-
Code:
else
     echo "<tr>"
     echo "<td>SRB</td>"
     echo "<td style="background-color:Red"> RED </td>"
     echo "</tr>"
     echo "</table>"
fi


Last edited by Yoda; 12-09-2012 at 03:30 AM..
This User Gave Thanks to Yoda For This Post:
# 7  
thanks a lot....i need to display like this if it is shutdown or unavailable


please check the below components
PRDU UCM Object code app UCM <b>Shutdown</b> Auto 0 20 1 1 2012-12-06 01:10:45

but wen i give like this

i getting mail full of "pls chk" along with output..

Code:
while read LINE
 do
 echo "pls chk below comp"
      echo $LINE | grep UCM | egrep '(Shutdown|Unavailable)'
 done <output.log

 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #1009
Difficulty: Easy
The number 128 in base 10 equals 64 in base 16.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

2. Homework & Coursework Questions

Help with redirecting output to an HTML file

1. The problem statement, all variables and given/known data: I'm having trouble redirecting the output of my sysinfo_page script into my sysinfo_page.html file. The task at hand is to be able to email both the html file and the script to myself. I'm assuming that the html should appear as a web... (8 Replies)
Discussion started by: braing
8 Replies

3. UNIX for Dummies Questions & Answers

Help with redirecting output to an HTML file

I'm very new to shell scripting and am practicing how to write a script, then redirect the output into an HTML file, and then email both the script and the HTML file to myself. I have created a script called sysinfo_page, and thought it would have redirected the output into the sysinfo_page.html... (3 Replies)
Discussion started by: braing
3 Replies

4. Shell Programming and Scripting

Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html can you please help me output.txt Token State Date1 Date2 Description Name 34567 open 27/06/13 28/06/13 ... (5 Replies)
Discussion started by: vijay_rajni
5 Replies

5. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

6. Shell Programming and Scripting

Removing all except couple of html tags from html file

I tried to find elegant (or at least simple) way to remove all but couple of html tags from html file, but all examples I found dealt with removing all the tags. The logic of the script would be: - if there is <li> or <ul> on the line, do nothing (=write same line to output) - if there is:... (0 Replies)
Discussion started by: juubuntu
0 Replies

7. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

8. Shell Programming and Scripting

how to display the output file in an html format using perl

Hi, I have written a perl script to dispaly some statements from a file but i want the output statements to be dispalyed in an HTML format.Is it possible for me to do in perl scripting? Please help me with ur thoughts. Thanks In Advance Meva. (1 Reply)
Discussion started by: meva
1 Replies

9. Shell Programming and Scripting

awk script to search an html file and output links

hello. i want to make an awk script to search an html file and output all the links (e.g .html, .htm, .jpg, .doc, .pdf, etc..) inside it. also, i want the links that will be output to be split into 3 groups (separated by an empty line), the first group with links to other webpages (.html .htm etc),... (8 Replies)
Discussion started by: kyris
8 Replies

10. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

Featured Tech Videos