[CentOS] Re: Probably a bad set-up but which one?

Mon Sep 29 16:11:32 UTC 2008
Tony Schreiner <schreian at bc.edu>

On Sep 29, 2008, at 11:32 AM, tech wrote:

> > Steve Huff wrote:
>> it would be easier to troubleshoot this problem if you were to  
>> post links to the following:
>> * your Perl script
>> * the Apache access and error logs showing what happens when you  
>> try to hit the CGI from a browser
>> * the relevant Apache configs (vhost, .htaccess, whatever)
>> -steve
>
> Steve,
>
> Thanks for the reply. Instead of links I will post the code as it  
> is very short.
>
> This is what the browser displays all on one line exactly as shown:
>
> Content-type: text/html Hello, world!
>
> Here is the index.html file:
>
> <html>
> <HEAD><TITLE>Tech</TITLE>
> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
> </head>
> <body>
> <p><!--#exec cmd="perl ./cgi-bin/hello.cgi"--></p>
> </body>
> </html>
>
> Here is the hello.cgi file:
>
> #!/bin/perl
> print "Content-type: text/html\n\n";
> print "Hello, world!\n";
>
> Here are the lines from the access log:
>
> 220.241.99.252 - - [29/Sep/2008:23:22:22 +0800] "GET / HTTP/1.1"  
> 200 189 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/ 
> 2008052912 Firefox/3.0"
>
> The error log has no lines for this access.
>
>
> Mel
>


I believe your HTML file has already caused the server to emit the

Content-type: text/html

line before it gets to the exec line; so when the perl program prints  
that line, it appears in the normal text output instead of as an HTTP  
directive. If you want to use the perl program this way, you're  
better of using it as a CGI instead of a server include file.

Tony Schreiner