免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5206 | 回复: 5
打印 上一主题 下一主题

[其他] 求助cgi [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-07-03 00:18 |只看该作者 |倒序浏览
大侠们好,

我有一个cgi程序几乎天天在用,但已经好几年没有改动了。今天改了一个小地方后,就突然不跑了。现在改回原来的码也没用。 返回的web页面是空白,
error log 是:

[..2014] [error] [client...] (2)No such file or directory: exec of '/home/coflo/cgi/gb/adm/source_ctl.cgi' failed
[..2014] [error] [client...] Premature end of script headers: source_ctl.cgi

请问这会是什么造成的?

谢谢

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
2 [报告]
发表于 2014-07-03 09:33 |只看该作者
第一行说明少了文件.

你不会是在 Windows下改的吧? 试着 dos2unix 一看看. 有时候perl 脚本的第一行 如果后面 多了 '^M' (vi下查看), 是不能正常执行的.

论坛徽章:
0
3 [报告]
发表于 2014-07-03 10:58 |只看该作者
谢谢大侠,
确实我是在windows xp底下编辑的,但是我上传时都会把\r去掉,
刚刚我用binary mode 打开查看,第一行
#!/usr/bin/perl
确实没有\r
但是还是不行,出来是空白页。
继续求助。。。

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
4 [报告]
发表于 2014-07-03 13:11 |只看该作者
回复 3# gary4096

直接在命令行执行一下这个脚本看看, 如果脚本本身有问题, 会直接把错误打出来的. 或者至少它应该把 header 打出来
   

论坛徽章:
0
5 [报告]
发表于 2014-07-03 14:04 |只看该作者
谢谢指导,

直接在命令行执行一下这个脚本就直接打出了html,没问参数,没报错。
还是不知道问题所在。。。

论坛徽章:
0
6 [报告]
发表于 2014-07-03 20:26 |只看该作者
谷歌搜寻,找到了下面:
suEXEC Problems
...and how to fix them.


When running a Perl CGI script, you may see the "premature end of script headers" error in your Apache error.log or error_log file.  This can be caused by some of the same problems (and fixed with some of the same fixes) as the Internal Server Error message.  However, this can also be caused by suEXEC errors, and in that case, it may give you no indication whatsoever that suEXEC is the cause.

Check if you have a /var/log/apache/suexec.log file; if so, and if it's the problem, it'll explain the reason why it's denying your script from executing properly.  One easy fix to try is adding a "-w" to the end of the first line of your Perl script, i.e. change the first line from "#!/usr/bin/perl" to "#!/usr/bin/perl -w" and see if that makes suEXEC happy.  Another common fix is to make sure that your CGI script has the same user/group ownership as your cgi-bin folder.

我把第一行加改为:
#!/usr/bin/perl -w

问题解决了,也十分感谢 q1208c 大侠!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP