#!/usr/bin/perl
$server_protocol = $ENV{'SERVER_PROTOCOL'};
$server_software = $ENV{'SERVER_SOFTWARE'};
print "$server_protocol 200 OK", "\n";
print "Server: $server_software", "\n";
print "Content-type: text/plain", "\n\n";
print "count from 1 to 50", "\n";
$¦ = 1;
for ($loop=1; $loop <= 50; $loop++) {
print $loop, "\n";
}
print "Done\n";
----
error log shows:
malformed header from script. Bad header=HTTP/1.1 200 OK:
I'm baffled. Got to be something simple-stupid. I used the above script because it is one passed around by Apache and I know it did work at one point.
What server type are you trying it on?
That's the header I get back (from test.cgi) - which of course goes to the 404 page - with return code 200. Is this the same script or are you working on something else?
print "Status: $server_protocol 200 OK", "\n"; [added]
Forget that last suggestion.
I still can't quite get the script to work but the info on here might help:
[hoohoo.ncsa.uiuc.edu...]
Script naming conventionsNormally, scripts produce output which is interpreted and sent back to the client. An advantage of this is that the scripts do not need to send a full HTTP/1.0 header for every request.
Some scripts may want to avoid the extra overhead of the server parsing their output, and talk directly to the client. In order to distinguish these scripts from the other scripts, CGI requires that the script name begins with nph- if a script does not want the server to parse its header. In this case, it is the script's responsibility to return a valid HTTP/1.0 (or HTTP/0.9) response to the client.
Now I have renamed the script I get the download prompt, so there still appears to be something not quite right with the headers.
[/added]
I renamed it to "nph-test.pl" and then it worked fine.
My guess is, either you have been silly like I was above, or if not that, for some reason on your system $ENV{'SERVER_PROTOCOL'} isn't returning the proper value.
BTW, welcome to wmw.