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.


Sign Up Now
> inserting command output in specific html table
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?

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

        <td>CPU Usage</td>
        <td>Disk Usage</td>

Go to the top of the page
+Quote Post
Start new topic
post Apr 6 2016, 05:42 AM
Post #2

Its GNU/

Group: Support Specialist
Posts: 1,807
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.


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

Posts in this topic

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: 21st July 2018 - 09:44 PM