CGI return problem

Posted By: rowanp ()
Posted On: 2005-Apr-13 13:01

Hi

When I get a page to return variables to a cgi script, my browser opens the cgi as a download file, instead of loading it as a webpage. How can I fix this?

Regards

rowanp.


Posted By: lizardz ()
Posted On: 2005-Apr-13 20:08

Is this on your own computer or on the webserver? I assume you're using a form to send some values to the cgi script? What script is it, is it a perl thing?

Perl scripts need some values added to make them run as perl scripts, the path to perl for example needs to be correct, that's on the first line of the script usually, like this:

#!/bin/perl5

or something like that.

If you're running this on your own box, of course you'll need a webserver and perl modules installed.

[ Message was edited by: lizardz 04/13/2005 12:46 pm ]




Posted By: rowanp ()
Posted On: 2005-Apr-13 20:59

It is on a server. You may be right about the path to perl. It may not be on the particular cgi file that I am working with.


Posted By: lizardz ()
Posted On: 2005-Apr-13 22:15

Usually you can get the path to perl from the hoster on their site, assuming you have a hoster, or from tech support.

If not, you can login with telnet or ssh, then just query the server directly for the perl path, like:

which perl
which perl5
whereis perl

or something like that, that should give you the path.


Posted By: Prowler (Staff)
Posted On: 2005-Apr-14 08:58

Your server will have been configured to run or execute files found only under some specific directory - usually cgi-bin. This directory will have specific permissions set to execute the files - whether they have the extension of cgi,pl, or whatever.

Only in that directory, the server will look at the shebang - the top line which defines which binary to use for the execution of the script.
For perl scripts, the shebang will be :
#!/usr/bin/perl
Your server may have been configured differently though.

In case if the path to the Perl binary is wrong, it will return the much dreaded Internal Server Error 500. It won't send the file as a text file to you through the browser.

So I suggest that you look for the directory - cgi-bin and dump your script there.


Posted By: rowanp ()
Posted On: 2005-Apr-14 09:02

I think that I have solved the problem. It was not the path to perl but the "Content text/html..." that was not being sent to the server.

Thanks for all your help.