Shell編程WEB界面展示實踐


操作系統:win7

虛擬機:Virtual box with Ubuntu13.10

WEB服務器: Nginx

WEB服務器發布目錄:/usr/local/nginx/html/c 

測試文件:list.txt

步驟:

1.新建一個shell腳本文件auto_html.sh.編輯內容如下:

#!/bin/bash
# created by bing

HTML=index.html
cat >$HTML <<EOF                            #HTML格式

<html>
<head>
<title>this is a test page[A]</title>
</head>
<body>
<table border="1" width="1000" cellpadding="0" cellspacing="0">
<tr><td>ID</td><td>IP address</td><td>DNS Name</td></tr>

EOF
while read line
do
ID=`echo $line|awk '{print $1}'`

IP=`echo $line |awk '{print $2}'`
NAME=`echo $line |awk '{print $3}'`

echo "<tr><td>$ID</td><td>$IP</td><td>$NAME</td></tr>" >>$HTML

done < list.txt                                        #測試文件

cat >>$HTML <<EOF                          #HTML格式
</table>
</body>
</head>
</html>
EOF

2.運行腳本./auto_html

 

3.查看生成的index.html

 

 4.配置本地hosts文件

 

5.啟動Nginx 服務器

 

6.瀏覽器中輸入網址http://www.test.com

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM