Help - Search - Members - Calendar
Full Version: inserting command output in specific html table
Linuxhelp > Support > Technical Support
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>

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
this helped. Thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.