CGI测试程序调试中的bug
时间:2009-04-29 来源:liningMCU
程序代码如下:
#include <stdio.h>
int main()
{
printf("Content-type: text/html\n\n") ;
printf("<html>\n") ;
printf("<head><title>CGI Output</title></head>\n") ;
printf("<body>\n") ;
printf("<h1>Hello, world.</h1>\n") ;
printf("</body>\n") ;
printf("</html>\n") ;
return 0;
}
编译步骤: arm-linux-gcc -o test.cgi test.c 调试步骤: 1.编译好后,我是通过Leapftp传到目标板上的,第一次传到/home/www/cgi-bin(/home/www/cgi-bin是在/etc/boa/boa.conf中指定的)目录下后,在浏览器中输入http://192.168.4.25/cgi-bin/test.cgi后,浏览器返回的信息为HTTP 403(禁止访问)错误; 2.然后在通过 chmod 755 /home/www/cgi-bin/test.cgi 命令修改其权限后,提示的错误为 502 Bad Gateway The CGI was not CGI/1.1 compliant 错误。 3.然后将Leapftp的上传模式改为二进制模式,(Leapftp的用户名和密码 后边有个 “自动”点自动就可更换模式)则一切OK,一个CGI的Hello,world程序终于调通了。 后记:在调试过程中其实走了很多弯路,如果直接采用nfs方式将test.cgi传到目标板上,则就不会出现上面的错误。
int main()
{
printf("Content-type: text/html\n\n") ;
printf("<html>\n") ;
printf("<head><title>CGI Output</title></head>\n") ;
printf("<body>\n") ;
printf("<h1>Hello, world.</h1>\n") ;
printf("</body>\n") ;
printf("</html>\n") ;
return 0;
}
编译步骤: arm-linux-gcc -o test.cgi test.c 调试步骤: 1.编译好后,我是通过Leapftp传到目标板上的,第一次传到/home/www/cgi-bin(/home/www/cgi-bin是在/etc/boa/boa.conf中指定的)目录下后,在浏览器中输入http://192.168.4.25/cgi-bin/test.cgi后,浏览器返回的信息为HTTP 403(禁止访问)错误; 2.然后在通过 chmod 755 /home/www/cgi-bin/test.cgi 命令修改其权限后,提示的错误为 502 Bad Gateway The CGI was not CGI/1.1 compliant 错误。 3.然后将Leapftp的上传模式改为二进制模式,(Leapftp的用户名和密码 后边有个 “自动”点自动就可更换模式)则一切OK,一个CGI的Hello,world程序终于调通了。 后记:在调试过程中其实走了很多弯路,如果直接采用nfs方式将test.cgi传到目标板上,则就不会出现上面的错误。
相关阅读 更多 +