Francesco del Vecchio wrote:
> I'm new to apache and linux.
> 
> I'm trying to run the "Hello World" cgi that works perfectly
> from terminal but via WebServer I
> obtain this error:
> 
> [Fri Mar 14 17:03:11 2003] [error] [client 127.0.0.1]
> Premature end of script headers: hello.pl
> 
> Do you have any idea about it?
> 
> the source is the following
> 
> #!/usr/bin/perl -w
> print ("ciao\n");

A CGI script needs to output a MIME header. At a bare minimum, you need to
add the following:

   print "Content-Type: text/plain\r\n\r\n",
       "ciao\n";

There are two \r\n pairs there because the header must end with a blank
line.

To do this with the CGI module (recommended), use:

   #!/usr/bin/perl -w
   
   use CGI ':standard';

   print header('text/plain'),
       "ciao\n";

If you want to output HTML instead of plain text, do something like this:

    #!/usr/bin/perl -w

    use CGI ':standard';

    print header,
        start_html('Ciao'),
        p('ciao'),
        end_html;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to