Jump to content

[Answered] Newbie: Problem With Running A Sample Cgi With Perl


Recommended Posts

Posted

Hi all.

I've recently got a free account from Heliosoft. Now, i'm unable to run even a simple cgi.

Is cgi active by default?

I've put a simple demo.cgi in cgi-bin with following code:

#!/usr/bin/perl

 

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

print <<HTML;

<html>

<head>

<title>A Simple Perl CGI</title>

</head>

<body>

<h1>A Simple Perl CGI</h1>

<p>Hello World</p>

</body>

HTML

exit;

 

Then, i've changed file permission to 755 (even 777) but i get following error all times:

Internal Server Error

 

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

Please contact the server administrator, webmaster@gistech.heliohost.org and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Any idea of what's wrong here?

 

Thanks in advance.

Posted
Is cgi active by default?

 

yup

Any idea of what's wrong here?

 

Nothing's wrong, as ExtremeGaming pointed out 500 errors are often caused by simple stuff like cPanel or phpMyAdmin being open, has to do with process limits on user accounts. Or when the server's got an extremely heavy load it'll spit 500 errors for most sites.

  • Like 1
Posted

Cgi can be really picky about permissions and syntax, and when it isn't exactly perfectly right it throws the very unhelpful 500 error.

 

Step one on troubleshooting is to make sure your cgi-bin directory and cgi file both have 755 permissions.

 

Step two is to make sure you're using the right shebang, which according to your code above looks right to me.

 

Step three is to make sure you set the correct content type.

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

Is what I use for perl cgi and it works on Heliohost. There may be other slight variations that work too.

 

Let us know if that doesn't fix the problem.

  • Like 1
Posted

Thanks a world, guys for your comments. Sorry for a bit latency (i thought it may take more time to get a response here. )

Anyway, I haven't opened phpMyAdmin yet.

I tried running cgi with closed cPanel but no help.

I checked permissions and they were both 755.

finally, I tried replacing second line with the line suggested by Support Admin but again no help.

 

So, problem is still unresolved for me.

Am i right with address, i.e. http://gistech.heliohost.org/cgi-bin/demo1.cgi

 

Regards

Posted

Alright, the next thing I would check would be the encoding on the file. Make sure it's not some crazy dos format with ^M's everywhere, or any other weird line endings. Like I said above cgi can be really picky about syntax, and line endings is just another tough to troubleshoot part of it.

  • Like 1
Posted

Thanks alot

the problem was with encoding, exactly EOL char. It was in windows format. Changing that to Unix solved everything.

 

Thanks again

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...