Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> inserting command output in specific html table
aristosv
post Apr 6 2016, 04:31 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 27-March 15
Member No.: 18,860



I use the following commands in a bash script, to output the CPU and disk usage on a computer.

I would like to import this output directly in an HTML file with tables.

How can I get the ouput of these commands to go in a specific table, as shown in the HTML code below?

CODE
echo $[100-$(vmstat|tail -1|awk '{print $15}')]'%'
df -h /dev/sda1 | awk 'NR>1{print $5}'


CODE
<html>
<head>
<title>Report</title>
</head>
<body>
<table>
    <tr>
        <td></td>
        <td>CPU Usage</td>
        <td>Disk Usage</td>
    </tr>
    <tr>
        <td>Computer1</td>
        <td></td>
        <td></td>
    </tr>
    </table>

</body>
</html>
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies (1 - 2)
michaelk
post Apr 6 2016, 05:42 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



You can create dynamic content using just about any language. Untested but you should get the general idea. You need to enable running scripts in your web server's configuration files. You can find out by googling.

CODE
#!/bin/bash

cpu=$( $[100-$(vmstat|tail -1|awk '{print $15}')] )
usage=$( df -h /dev/sda1 | awk 'NR>1{print $5}' )

echo "Content-type: text/html"
echo ""

echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '<title>Report</title>'
echo '</head>'
echo '<body>'
echo '<table>'
   echo '<tr>'
         echo  ' <td></td>'
        echo '<td>CPU Usage</td>'
        echo '<td>Disk Usage</td>'
    echo '</tr>'
    echo '<tr>'
        echo '<td>Computer1</td>'
        echo "<td>$cpu</td>"
        echo  "<td>$usage</td>"
     echo '</tr>'
     echo '</table>'
echo '</body>'
echo '</html>'

exit 0
Go to the top of the page
 
+Quote Post
aristosv
post Apr 7 2016, 06:30 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 27-March 15
Member No.: 18,860



this helped. Thanks
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th November 2017 - 10:50 PM