shell腳本--編寫CGI代碼
阿新 • • 發佈:2018-03-14
tle ext .html targe world set echo 寫代碼 shell
推薦 初始CGI ,看完大概之後,大概對cgi有個大體的印象。下面是在cgi腳本中實現shell和html標簽混合的方式編寫代碼:
#!/bin/bash #index.cgi echo "Content-Type:text/html;charset=utf-8" echo echo ‘<html>‘ echo "<head>" echo "<title>" echo "hello world" echo "</title>" echo "</head>" echo "<body>" echo ‘<pre>‘ df -Th echo ‘<pre>‘ echo "</body>" echo "</html>"
瀏覽器訪問:
將上面代碼簡化一下:
#!/bin/bash #index.cgi echo "Content-Type:text/html;charset=utf-8" echo cat << AAA <html> <head> <title>hello world</title> </head> <body> <pre> AAA df -Th cat << AAA </pre> </body> </html> AAA
shell腳本--編寫CGI代碼