CGI-Perl on Apache problem

PROBLEM

Running a simple “hello world” script under Apache-CGI gives ERROR 500.

1. Running a “hello world” script with print “hello world\n” in the end;

[Sun Dec 14 10:02:32 2008] [error] [client 68.72.82.204] malformed header from script. Bad header=hello world: hello_world.pl

2. Running a “hello world” script without print “hello world\n” in the end;

[Sun Dec 14 10:11:44 2008] [error] [client 68.72.82.204] Premature end of script headers: hello_world.pl

SOLUTION (simple and outrageous)

Add a double \n at the end of print “Content-type: text/plain”.

#!/usr/bin/perl -w
print “Content-type: text/plain\n\n“;
print “hello world\n”;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s