Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert output to .html file 1

Status
Not open for further replies.

mregotman

Instructor
Mar 20, 2011
6
US
how would I get the output of this to be in an a .html file..I tried putting the echo >> command on each line to send it to a file called out.html but doesn't come out ..do i need to put the html header at top?

#!/bin/bash

dans=`netstat -an | grep 127.0.0.1.8883 | awk '{print $4}' | grep 127.0.0.1.8883`

if [ "$dans" = "127.0.0.1.8883" ]; then
echo "Dansguardian" "[ OK ]"
else
echo "Dansguardian" "[ DOWN ]"
fi

squid=`netstat -an | grep 127.0.0.1.3338 | awk '{print $4}' |grep 127.0.0.1.3338`

if [ "$squid" = "127.0.0.1.3338" ] ; then
echo -e Squid "\t\t" "[ OK ]"
else
echo -e Squid "[ DOWN ]"
fi

 
Here is an example of a 'boilerplate' HTML envelope which has a Server Side Include of a shellscript output file. Your script output may contain HTML tags as necessary if you wish.

Hint: your HTML envelope will have a file extension of '.shtml'.


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<HTML>
  <HEAD>
    <TITLE>PAGE TITLE GOES HERE</TITLE>
  </HEAD>
  <BODY>
    <CENTER>
    <H2>SOME HEADER TEXT GOES HERE</H2><br>
    <!-- #include file = "/youroutputfile.txt" -->
    </CENTER>
  </BODY>
</HTML>
 
An Alternative method.

Just output to a text file then run it through txt2html


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Also, most web servers will serve a text file as is. Just give it the extension "[tt].txt[/tt]" and use that in the URL you request it with, not "[tt].html[/tt]". Your browser should display it as fixed width text (mine does).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top