/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(); 即可解決

Related posts 相關文章
2020 年迎來了 PHP 8 與 Perl 7
More...
安裝 perl 5.8.1 版本 – 草記
More...
perl 備註
More...
perl 隨機產生 password 密碼
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。