操作系統: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