can't run cgi scripts

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
sdoyle
Guest





PostPosted: Sat Oct 05, 2002 9:13 am    Post subject: can't run cgi scripts Reply with quote

I want to run cgi scripts locally, but can't seem to get them to work. If I run the script from the browser (IE), it seems to work. If I try to run it via an HTML document, I get a blank screen or a pop-up screen asking me if I want to download the file. I have installed an interpreter. Also, if I try to run the HTML file from the browser it says that the file isn't available offline. I would appreciate any help I can get.
Back to top
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Oct 05, 2002 8:40 pm    Post subject: Re: can't run cgi scripts Reply with quote

sdoyle wrote:
I want to run cgi scripts locally, but can't seem to get them to work. If I run the script from the browser (IE), it seems to work. If I try to run it via an HTML document, I get a blank screen or a pop-up screen asking me if I want to download the file. I have installed an interpreter. Also, if I try to run the HTML file from the browser it says that the file isn't available offline. I would appreciate any help I can get.

First of all, CGI scripts can't be run from IE. It is a web browser and it can't do that. So what scripts are you trying to run, and in which language ?
As a general rule, you should install the correct interpreter that will run your scripts and you should put them /cgi-bin or in any directory or subdirectory declared in CGI Paths.
CGI Scripts do not have html extension. Traditionnaly, .php is for PHP scripts, .pl or .cgi for Perl and .asp for Active Server Pages.
So please read our documentation carefully and if you still run in trouble, resubmit us a more detailed question.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
sdoyle
Guest





PostPosted: Sat Oct 05, 2002 9:17 pm    Post subject: can't run cgi scripts Reply with quote

OK, here's what I'm trying to do. I'm just starting to learn to write cgi scripts using Perl. I want to be able to run them locally on my computer to test them to see if they work. This was recommended by the book I'm studying.
I'm trying to run a form script that returns data entered into a form. Here is what it looks like.

#!C:\Perl\bin\perl

use CGI ':standard':

my @name, @mail;

@name = param('name');
@mail = param('email');

print "Content-type: text/html\n\n";
print "<html><head><title>Parsing Form Data</title></head><body>\n";
print "<b>Hello, @name. Here is the data from the form you just
submitted:</b>\n\n<br><p><br>";
print "Name: @name<br>\n";
print "Email: @mail<br>";
print "</body></html>";


I'm trying to access the script via HTML by using:

<html>
<body>
<form action="/cgi-bin/steve.cgi" method=POST>

Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>

<input type="submit" value="Submit"><br>
<input type="reset" value="Clear"><br>
</body>
</html>
when I type in input and submit I get either a blank page or a prompt to download the cgi file.

Also, if I open up IExplorer and type in the address:
http://localhost/cgi-bin/steve.cgi
it shows the output I should be getting from the script

"Hello..Here is the data from the form you just submitted"

I hope this is enough info.Thanks for the help.
Back to top
J. Patrick
-


Joined: 26 Aug 2002
Posts: 42
Location: Pittsburgh, PA USA

PostPosted: Sun Oct 06, 2002 12:46 am    Post subject: Reply with quote

The reason for that is because you are viewing the file right from your PC.

When you access localhost the server interprets the file and gives you the result. The server also knows what to do with the file unlike IE which just downloads anything that it doesn't know a mime type for. To put it simply CGI is server-side means it needs to be run from the server, in your case it was ran from something like c:\programs\abyss\htdocs\ which in no way directly contacts the server asking it to do anything.

On the other hand JavaScript for example is client-side meaning the browsers does all the work.

I hope I have answered your question.

-Patrick
Back to top View user's profile Send private message Send e-mail AIM Address
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Oct 06, 2002 1:34 am    Post subject: Re: can't run cgi scripts Reply with quote

sdoyle wrote:
OK, here's what I'm trying to do. I'm just starting to learn to write cgi scripts using Perl. I want to be able to run them locally on my computer to test them to see if they work. This was recommended by the book I'm studying.
I'm trying to run a form script that returns data entered into a form. Here is what it looks like.

#!C:\Perl\bin\perl

use CGI ':standard':

my @name, @mail;

@name = param('name');
@mail = param('email');

print "Content-type: text/html\n\n";
print "<html><head><title>Parsing Form Data</title></head><body>\n";
print "<b>Hello, @name. Here is the data from the form you just
submitted:</b>\n\n<br><p><br>";
print "Name: @name<br>\n";
print "Email: @mail<br>";
print "</body></html>";


I'm trying to access the script via HTML by using:

<html>
<body>
<form action="/cgi-bin/steve.cgi" method=POST>

Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>

<input type="submit" value="Submit"><br>
<input type="reset" value="Clear"><br>
</body>
</html>
when I type in input and submit I get either a blank page or a prompt to download the cgi file.

Also, if I open up IExplorer and type in the address:
http://localhost/cgi-bin/steve.cgi
it shows the output I should be getting from the script

"Hello..Here is the data from the form you just submitted"

I hope this is enough info.Thanks for the help.

OK. The problem is that you need to declare the cgi extension as handled by Perl (the same as you should do with pl extension). See http://www.aprelium.com/abyssws/perl.html for more information.
By following the last method, the #! becomes not useful and you can delete it.
Your script will run fine now (if it doesn't contain errors of course :wink: ).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
sdoyle
Guest





PostPosted: Sun Oct 06, 2002 7:44 am    Post subject: cgi scripts Reply with quote

So with all that being said and done. Is it at all possible for me to test my cgi scripts locally instead of uploading files to an external web server?

Ps-I do have the extensions cgi and pl associated with perl

thanks for the help
Back to top
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Oct 06, 2002 9:48 pm    Post subject: Re: cgi scripts Reply with quote

sdoyle wrote:
So with all that being said and done. Is it at all possible for me to test my cgi scripts locally instead of uploading files to an external web server?

Ps-I do have the extensions cgi and pl associated with perl

thanks for the help

When you use Abyss Web Server, you do not require an internet connection. You can host a local web site and test it locally. Just use 127.0.0.1 as the web site IP (http://127.0.0.1). Put the files you want to test in the htdocs directory using Windows Explorer (you don't need an FTP server for that).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
sdoyle
Guest





PostPosted: Tue Oct 08, 2002 1:10 am    Post subject: can't run cgi scripts Reply with quote

Works great! This is exactly what I wanted to do. Thanks so much for the help.

Steve
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group