無法瀏覽 CGI 程式 (perl) malformed header from script. Bad header=<html>
作者: cross 日期: 2008-09-16 06:30
/var/log/httpd/error_log
malformed header from script. Bad header=<html>
ref: http://cs.uccs.edu/~cs301/perl/perl.htm
Basically the web server complains that the wrongHello.cgi returns a web page without proper header such as "content-type: text/html " before the body of the web page <html>HelloWorld!. The header is required as the CGI secification or CGI protocol between the CGI process running the wrongHello.cgi and that of the web server. For more detail see the CGI web page.
The above hello.pl is perl script can be run standalone. It is not a CGI perl script since it did not follow the CGI protocol. In order to make that as a CGI perl script, we need to add the following two lines after #!/usr/bin/perl
use CGI qw(:standard);
print header();or
print "content-type: text/html ";
Try http://sanluis.uccs.edu/~cs301/cgi-bin/hello.cgi or http://sanluis.uccs.edu/~cs301/cgi-bin/hello2.cgi, src, which implement the above fixes.
看到這錯誤訊息時,在 print "<html> "; 前加上 use CGI qw(:standard); print header(); 即可解決
上一篇
返回
下一篇
標籤:




perl 所謂的參照 (2011-08-02 23:59)
perl 的map功用 (2011-08-02 23:18)
perl 關於排序功能 (2011-08-02 22:41)
perl 如何輸入密碼時以星號*顯示 (2011-05-14 19:31)
perl 怎麼達到 ls 功能 (續) (2011-04-19 12:05)
perl 模組 - package範例 (2011-04-03 22:43)
編譯perl模組遇到的問題 (2011-03-07 16:27)
perl 一個可以學習怎麼寫CGI程式的地方 (2010-05-01 00:44)
perl 程式存取 MS Access MDB 資料庫 (續) UPDATE語法 (2010-03-12 10:58)