首先创建booka.cgi脚本,内容如下:
#!/bin/sh
#booka.cgi
echo "Content-type: text/html"
echo ""
echo ""
echo ""
#call booka_result,cgi,when user hits sent!
echo "
echo "
CGI FORM
"#text box,input assigned to variable name 'contact'
echo "Your name:
"
#drop down menu selection assigned to variable name 'film'
echo ""
# drop down menu selection assigned to variable name 'actor'
echo ""
echo "
"
#check box variable names are 'view_cine' and 'view_vid'
echo "Do you want films at the..
"
echo " Cinema"
echo " On Video"
echo "
"
#input assigned to variable name 'textarea'
echo "Tell what is your best film,or just enter some comments
"
echo ""
echo "
"
echo ""
echo ""
echo ""
echo ""
再创建booka_resule.cgi文件,使用户按下send按钮后,执行该脚本,内容如下:
#!/bin/sh
#booka_result.cgi
#print out the web server env for a get
echo "Content-type: text/html"
echo ""
echo "
"
echo """
echo "Results from a GET form"
echo "REQUEST_METHOD : $REQUEST_METHOD"
echo "QUERY STRING : $QUER_STRING"
echo "
这两个文件都放在/usr/lib/cgi-bin目录下,并把起权限都设为了755
在firefox中访问第一个脚本,出现:[attach]16839[/attach]
但是按下send和clear按钮都没有反应。是在ubuntu下进行的。
其他不带get的简单脚本都可以显示的。
不知道是firefox浏览器不支持get方法,还是脚本本身的问题。
请各位不吝赐教,谢谢~~
wang7131984 于 2009-06-22 23:18:09发表:
1,你没有启动http服务器,get/post请求发送出去没有程序解释执行
2,你的路径不正确/cgi-bin/(根目录下的cgi-bin目录下的xx脚本,这个目录是错的),都在一个目录下加个/cgi-bin不是多此一举。而且你这个是个绝对路径的写法。而实际上web应用程序很少用绝对路径。
3,几乎没有用shell编写cgi的,perl,php,ruby,python这些都是强大的cgi语言,何必要用个系统管理的shell来编写cgi。