Results 1 to 3 of 3

Thread: CGI script not working...

  1. #1
    Join Date
    Nov 2006
    Posts
    2

    Default CGI script not working...

    Hi,

    I have placed a simple Perl cgi script in the cgi-bin folder to test and it does not work. I double checked to see if the Apache cgi handler has been added and it is. The file attributes were also set to 755.

    The Perl code is a simple hello world script:

    Code:
    #!/usr/bin/perl
    print "<h1>Hello world!</h1>";
    I get this error message when I try to run the script:

    500 Server Error
    A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.

    I tried looking at the server logs but there were no errors related to the cgi script that was logged.

    Please help. Thank you in advance.

    newb
    Last edited by aliu; 11-01-2006 at 05:29 PM.

  2. #2
    Join Date
    Oct 2006
    Posts
    358

    Default

    Unlike PHP, Perl does not print headers for you automatically. So the first line you output has to be something like "Content type: text/html". Try this:

    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<BODY BGCOLOR=#FFFFFF>\n";
    print "<h1>Hello world!</h1>";
    print "</body></html>"
    Did that fix it?

  3. #3
    Join Date
    Nov 2006
    Posts
    2

    Default It worked!

    It turns out that the following line was crucial:

    print "Content-type: text/html\n\n";

    Thanks Pethens!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •