English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I can make a form using html but to make it functional I need to know cgi script. I am taking a course but haven't gotten to that yet so I wanted to try to teach it to myself. But all this stuff confused me. You need Perl for cgi, so I downloaded what it said to download and all it is is some blue box. I type what it said to type and it's an invalid command. Anyway can someone explain this perl and cgi in simple terms to a complete beginner.

2006-09-18 17:33:42 · 5 answers · asked by BereaGirl 3 in Computers & Internet Programming & Design

5 answers

First off perl is not needed for CGI. It is a "Common Gateway Interface" that can use any language. I've seen scripts in C, unix shell and other languages. Perl happens to be well suited to CGI and thus has become quite popular. Perl needs to be installed on the webserver to use it.

Also, there are many other options that can be used to make sites dynamic. PHP, ASP, JSP are just some of the options.

For basic CGI, first the webserver needs to be configured to process CGI. A common way to do this is to create a cgi-bin directory, and set the CGI handler on that directory. When this is set up, the web server will run programs in that directory, instead of just printing them out like html pages.

Next you need to create the programs there. If this is a Unix box, a simple script could be:

#!/usr/local/bin/perl -w
print "Content-type: text/html\n\n";
print "

Hello, World

\n";

If you save this as script.cgi in the cgi-bin directory, you should be able to run it by going to a URL "/cgi-bin/script.cgi". When you go there on a web site, it should print Hello, World in a large font.
(Note: the first line is the path to where 'perl' is installed. This should be the directory where you installed it, or you could find it by "which perl")

You should also be able to run this manually on the command. line. You could go in to the cgi-bin directory and run ./script.cgi. The output would be slightly different when doing this. The script itself must have execute permission in order to run.

If you are using a hosting service, then they might have everything already set up for you. You just need to make sure you have things in the right directories, and don't have any typos in your scripts. (CGI scripts can be very unforgiving if they have typos, and will often just show a blank page or irrelevant error message. In perl you can use the CGI Carp module to get more meaningful CGI output.)

Often an html page will have a POST ACTION that contains a URL to a CGI script. This script will then parse the post results, and then output some appropriate page.

2006-09-22 11:59:40 · answer #1 · answered by LDude7 2 · 0 0

To run cgi scripts you need Perl running on a web server. If you want to run it on your computer, downloading Perl is just the first step. You need to have web hosting software running on your computer, and configured to run Perl. You don't say what kind of Perl you're running or what platform, but the default installation of ActivePerl on Windows just runs in a command window and doesn't support cgi.

If you have access to a web host for your course, you can upload your cgi scripts there and try them; you don't need anything but a text editor on your computer then.

2006-09-19 03:34:33 · answer #2 · answered by injanier 7 · 0 0

This may be too complex for you at your level. Best to wait to you do your course, and use a free online service for form processing in the meantime.

Try one of these services:

http://cgi.resourceindex.com/Remotely_Hosted/Form_Processing/

2006-09-19 01:11:16 · answer #3 · answered by 4 · 0 0

why dont u learn asp,asp.net or php?if u are beginner install activeperl software and enter to the wastelands of perl

:)) just killing

2006-09-19 02:59:48 · answer #4 · answered by ibrahim ersoy 2 · 0 0

it solve client request by .exe or .dll

2006-09-19 00:41:37 · answer #5 · answered by Nam Nguyen 2 · 0 0

fedest.com, questions and answers