尊敬的人......
我在openSUSE 12.2上,我的Apache服务器正常运行......
我复制了index.html,其中包含:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>Program 7b</title></head>
<body>
<form method="POST" action="http://localhost/cgi-bin/7b.pl">
Please Enter the Command :
<input type="text" name="command" id="command" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
和perl文件如下:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI
$a = new CGI;
$comm = $a->param("command");
print "The Output of the entered command is:<br />";
system($comm);
cgi-bin目录中的两个文件
但我得到错误:
脚本标头过早结束 在任何浏览器中运行localhost / cgi-bin / index.html ....
我已经在apache配置中设置了perl文件的执行...
请帮助解决问题...
此致 -SkyKOG
答案 0 :(得分:0)
Apache将index.html作为脚本运行,而不仅仅是显示HTML文档。 Apache可能被配置为在cgi目录中以脚本的形式运行任何内容。
将html文件移动到另一个目录中。
答案 1 :(得分:0)
尝试以下工作代码:
#!/usr/bin/perl
use strict; use warnings;
use CGI;
print "Content-type:text/html\n\n";
my $a = new CGI;
my $comm = $a->param("command");
print "The Output of the entered command is:<br />";
system($comm);
建议:永远不要忘记use strict; use warnings;
并使用my
或our
声明变量。