0

Hello

I have got a LAMPP Webserver. I tried to open a CGI Script called "Hello.cgi".

It contains:

#!/usr/bin/perl
print "Hello World.\n";

The path is: /opt/lampp/htdocs/dashboard/cgi-bin/hello.cgi

When I open: "127.0.0.1/dashboard/cgi-bin/hello.cgi", I get following:

Server error!

The server encountered an internal error and was unable to complete your request.

Error message: End of script output before headers: hello.cgi

If you think this is a server error, please contact the webmaster.

The CGI Script is written in Perl.

If you need more informations about my problem, say it, please.

~~runasas

runasas
  • 21
  • 1
  • 1
  • 4

1 Answers1

0

Firstly, you should never write a Perl program without including the lines use strict; and use warnings;.

Secondly, if you have problems with a CGI program, you should check the web server error log for more details of the problem.

Thirdly, the output from a CGI program needs to include a content type header. So you'll want to add the following:

print "Content-Type: text/plain\015\012\015\012";

This becomes easier if you use the CGI module:

use CGI;
print header('text/plain');

But really, in 2016, you shouldn't be writing CGI programs - there are plenty of good alternatives available.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97