【发布时间】:2013-07-06 05:16:07
【问题描述】:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: askName.pl
这是我的代码...
#!/usr/bin/perl
#askName.plx
#use 5.006;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
print "Content-type: text/html\n\n";
my $cgi = new CGI;
print"<html><head><title> Forms Intro! </title></head>"; print "<h1> Welcome, ",$cgi ->
param('first'), " " , $cgi -> param('last'), "</h1>"; print"</html>";
我也试过这样格式化
print $cgi -> header();
print $cgi -> start_html("Welcome");
print "<h1> Welcome, ",cgi -> param('first'), " " , $cgi -> param('last');, "</h1>";
print $cgi -> end_html();
但它不起作用:/
【问题讨论】:
-
这段代码在我的服务器上运行没有错误。您尝试在哪种类型的 Web 服务器上运行它?我的猜测是这是一个配置问题。您是否在此 Web 服务器上运行了其他 perl 脚本?如果是这样,它们运行没有问题吗?如果是这样,请查看其他脚本与您的脚本之间的差异。如果它们都没有运行,则需要更改服务器上的一些设置。
-
另外,尝试从命令行运行它,看看你的输出是什么。您应该看到您的 html 标题和一些基本的 html 结构。如果您不明白,您至少可能会收到一条有用的错误消息。
-
谢谢,我试试看,不胜感激
-
虽然建议在 daxim 引用的答案中,但您的脚本未运行的原因应该存储在您的 Web 服务器的错误日志中(可能是
/var/log/apache2/error.log或任何设置的 ErrorLog在您的/etc/apache*/*.conf文件中)