SHELL 產生HTML

來源:互聯網
上載者:User

標籤:

#!/bin/bash# 示範使用 shell 指令碼建立 HTML 報告的樣本指令碼# Web directoryWEB_DIR=/var/www/html# A little CSS and table layout to make the report look a little nicerecho "<HTML><HEAD><style>.titulo{font-size: 1em; color: white; background:#0863CE; padding: 0.1em 0.2em;}table{border-collapse:collapse;}table, td, th{border:1px solid black;}html{text-align:center;}</style><meta http-equiv=‘Content-Type‘ content=‘text/html; charset=UTF-8‘ /></HEAD><BODY align=center>" > $WEB_DIR/report.html# View hostname and insert it at the top of the html bodyHOST=$(hostname)echo "Filesystem usage for host <strong>$HOST</strong><br>Last updated: <strong>$(date)</strong><br><br><table border=‘1‘><tr><th class=‘titulo‘> HOSTNAME</td><th class=‘titulo‘>IP</td></tr>" >> $WEB_DIR/report.html#擷取IPifconfig|grep "inet addr:"|while read line; doecho "<tr><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $HOST >> $WEB_DIR/report.htmlecho "</td><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk -F ‘:‘ ‘{print $2}‘| awk -F‘ ‘ ‘{print $1}‘ >> $WEB_DIR/report.htmlecho "</td></tr>" >> $WEB_DIR/report.htmldoneecho "</table><br><br><table border=‘1‘><tr><th class=‘titulo‘> Machine Info</td><th class=‘titulo‘>Value</td></tr>" >> $WEB_DIR/report.html#擷取機器SN號dmidecode -t 1|egrep -e "Product|Serial"|while read line; doecho "<tr><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk -F ‘:‘ ‘{print $1}‘ >> $WEB_DIR/report.htmlecho "</td><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk -F ‘:‘ ‘{print $2}‘ >> $WEB_DIR/report.htmlecho "</td></tr>" >> $WEB_DIR/report.htmldoneecho "</table><br><br><table border=‘1‘><tr><th class=‘titulo‘>Filesystem</td><th class=‘titulo‘>Size</td><th class=‘titulo‘>Use %</td></tr>" >> $WEB_DIR/report.html# 擷取硬碟使用方式df -Ph | grep -vi 檔案系統|while read line; doecho "<tr><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk ‘{print $1}‘ >> $WEB_DIR/report.htmlecho "</td><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk ‘{print $2}‘ >> $WEB_DIR/report.htmlecho "</td><td align=‘center‘>" >> $WEB_DIR/report.htmlecho $line | awk ‘{print $5}‘ >> $WEB_DIR/report.htmlecho "</td></tr>" >> $WEB_DIR/report.htmldoneecho "</table></BODY></HTML>" >> $WEB_DIR/report.html

SHELL 產生HTML

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.