Operating System - HP-UX
1748287 Members
3272 Online
108761 Solutions
New Discussion

not able to capture remsh outputs in table format

 
Madan Kumar
Occasional Advisor

not able to capture remsh outputs in table format

Hi All,

 

I am trying to capture date/time from all servers from a centralized server, I can see remsh output on my screen but dont see output in html tabular format, please help, below is the script.

 

cat ntp3.sh
#!/bin/sh

cd /home/mkb/scripts

echo "<html>" > WWP_TZ.html;

echo "<body>" >> WWP_TZ.html;

echo "<pre>" >> WWP_TZ.html;

echo "<h1> WWP TimeZone Change Report </h1>"  >> WWP_TZ.html;

for i in `cat /home/mkb/scripts/HOST`
                do
                        Hostname=$i
                        T_Z=$(remsh $i echo $TZ)
                        DateZ=$(remsh $i date +%Z)
                        DateH=$(remsh $i date)
echo "<tr>" >> WWP_TZ.html ;
echo "<td>" >> WWP_TZ.html ;echo $Hostname ; echo "</td>" >> WWP_TZ.html;
echo "<td>" >> WWP_TZ.html ;echo $T_Z ; echo "</td>" >> WWP_TZ.html;
echo "<td>" >> WWP_TZ.html ;echo $DateZ ; echo "</td>" >> WWP_TZ.html;
echo "<td>" >> WWP_TZ.html ;echo $DateH ; echo "</td>" >> WWP_TZ.html;
echo "</tr>" >> WWP_TZ.html ;
                done
echo "</pre>" >> WWP_TZ.html;
echo "</body>" >> WWP_TZ.html;
echo "</html>" >> WWP_TZ.html;

5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: not able to capture remsh outputs in table format

You don't have any tags to actually define the table itself.

 

A basic table in html is:

 

<table>

<tr>

<td>data</td>

<td>more data </td>

</tr>

</table>

 

You need to add the <table> and </table> tags in the appropriate spot in your script.  I think that will help.

 

For example:

 

<table>

for i in `cat /home/mkb/scripts/HOST`
                do

...

...

...

done

</table>
echo "</pre>" >> WWP_TZ.html;

Dennis Handly
Acclaimed Contributor

Re: not able to capture remsh outputs in table format

You may want to use here docs to make your script easier to understand:

cat <<EOF > WWP_TZ.html;

<html>
<body>
<pre>
<h1> WWP TimeZone Change Report </h1>
EOF


for i in $(< /home/mkb/scripts/HOST);   do

   Hostname=$i
   T_Z=$(remsh $i echo $TZ)
   DateZ=$(remsh $i date +%Z)
   DateH=$(remsh $i date)

   cat <<EOF >> WWP_TZ.html

<tr>
<td> $Hostname </td>
<td> $T_Z </td>
<td> $DateZ </td>
<td> $DateH </td>
</tr>

EOF
   done

cat <<EOF >> WWP_TZ.html
</pre>
</body>
</html>

EOF

Patrick Wallek
Honored Contributor

Re: not able to capture remsh outputs in table format

Good morning,

 

I was looking more at your script and figured out some more issues.

 

The first is, still, that you do not have the <table> and </table> tags to define the table.

 

However, your main issue is that you are not redirecting the Hostname, T_Z, DateZ and DateH variables into your file.  You are doing an 'echo' but the information is just echoing to the screen and not going into your HTML file.

 

Here is my modified version of your script:

 

#!/bin/sh

cd /home/mkb/scripts

echo "<html>" > WWP_TZ.html
echo "<body>" >> WWP_TZ.html
echo "<pre>" >> WWP_TZ.html
echo "<h1> WWP TimeZone Change Report </h1>"  >> WWP_TZ.html
echo "<table border=2>" >> WWP_TZ.html
echo "<tr>" >> WWP_TZ.html
echo "<td>Hostname</td>" >> WWP_TZ.html
echo "<td>TZ</td>" >> WWP_TZ.html
echo "<td>date +%Z</td>" >> WWP_TZ.html
echo "<td>date</td>" >> WWP_TZ.html
echo "</tr>" >> WWP_TZ.html

for i in $(< /home/mkb/scripts/HOST)
do
Hostname=$i T_Z=$(remsh $i echo $TZ) DateZ=$(remsh $i date +%Z) DateH=$(remsh $i date) echo "<tr>" >> WWP_TZ.html echo "<td> $Hostname </td>" >> WWP_TZ.html echo "<td> $T_Z </td>" >> WWP_TZ.html echo "<td> $DateZ </td>" >> WWP_TZ.html echo "<td> $DateH </td>" >> WWP_TZ.html echo "</tr>" >> WWP_TZ.html done echo "</table>" >> WWP_TZ.html echo "</pre>" >> WWP_TZ.html echo "</body>" >> WWP_TZ.html echo "</html>" >> WWP_TZ.html

 

Dennis Handly
Acclaimed Contributor

Re: not able to capture remsh outputs in table format

>You are doing an 'echo' but the information is just echoing to the screen and not going into your HTML file.

 

Yes, my here doc would make it obvious.  I just happened to fix it without thinking when I converted it.

Also lines can be combined if desired.

Laurent Menase
Honored Contributor

Re: not able to capture remsh outputs in table format

Do you mean that your terminal program has a html interpreter included?