Dav*_*edy 1 html bash cgi openwrt sh
我在OpenWrt 12.09上运行uhttpd.我在/ www/cgi-bin/test上有一个shell脚本,如下所示:
#!/bin/sh
echo "Content-type: text/html"
echo "<p>It works!</p>"
Run Code Online (Sandbox Code Playgroud)
我通过这样做给了文件执行权限chmod +x.所有者是root,uhttpd以root身份运行.
现在,当我去的时候,http://192.168.1.1/cgi-bin/test我得到一个错误:
The CGI process did not produce any response
Run Code Online (Sandbox Code Playgroud)
系统或内核日志中没有错误.
我可以去http://192.168.1.1/cgi-bin/luci获取LuCI登录页面,因此其他CGI脚本正在运行.该文件具有不同的shebang(#!/usr/bin/lua)但两个脚本具有相同的权限和所有者.
我究竟做错了什么?
有必须是HTTP报头和主体之间的空行.此外,您可能想要提供完整的HTML文档.
#!/bin/sh
echo "Content-type: text/html"
echo
echo "<html><head><title>hello world</title></head><body><p>It works!</p></body>"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2938 次 |
| 最近记录: |