[100623] in RedHat Linux List
RE: Apache/WebServer-CGI scripts &
daemon@ATHENA.MIT.EDU (Charles Galpin)
Sun Nov 22 12:52:05 1998
Date: Sun, 22 Nov 1998 12:49:26 -0500
From: Charles Galpin <cgalpin@lighthouse-software.com>
To: "redhat-list@redhat.com"@smtp2.erols.com
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
Marc
It's best to keep things really simple until you understand what you are
doing. The first thing I would do if I were you is learn perl a bit better,
or use a language you are more familiar with. Your program should compile
cleanly with perl -c query.pl before you even think about using it as a cgi.
You should also make it executable.
1. your html is ok, except that you will have to hit enter after typing in a
name before anything will happen. Or you culd add
<INPUT TYPE="submit">
after your other input to get a button to click.
2. There were too many problems in your script to even attempt to fix it.
Here is a simple strting point. Get this to work on your system before
moving foward.
#!/usr/bin/perl
require "cgi-lib.pl";
print &PrintHeader;
if (&ReadParse(*input)) {
print "Thank you, $input{ USERNAME }, for submitting your
comments.<br>\n";
} else {
print "An error occured parsing the form input.<br>\n";
}
I hope this helps. I saw a discussion earlier about CGI scripting, and just
want to point out that this is just a simple specification of how a web
browser or other program can interact with a program launched be a web
server. I think the term gets far too much awe and respect than it deserves
from those who have not used it.
It stands for Common Gateway Interface. Any, and I mean any programming
language (including a simple DOS .bat script) can be used to do cgi
programming. The only requirements are these
It can read environment variables (this can be worked around with wrappers
too)
It can read from stdin (for POST)
It can write to stdout.
Beyond the simple details of how to get the form input from the environment
variables and stdin, and how to send the correct header to standard out, the
program can do anything it wants, any way it wants (with some limitations of
course ).
charles
===== Original Message from redhat-list@redhat.com at 11/22/98 3:43 am
>Hi,
>Hundred thanks for your great generous help.
>I ve transformed my simple index.html file as follow:
><HTML><HEAD><TITLE>My Apache web server</TITLE></HEAD>
><BODY>
><P>
><FORM METHOD="post" ACTION="http://Localhost/cgi-bin/query.pl">
>Enter Username
><INPUT TYPE="TEXT" NAME="USERNAME" SIZE="25" MAXLENGTH="50" VALUE="">
></FORM></BODY></HTML>..
>I ve also modified my /home/httpd/cgi-bin/query.pl file as follow
>(BTW,thanks to some of you):
>#!/usr/bin/perl
>require ("cgi-lib.pl"); # I even tried "require cgi-lib.pl"
>&ReadParse;
>print <<EOF;
>Content-type: text/html
>$line=QUERY_STRING # I even tried "setenv QUERY_STRING USERNAME=spike
> #BTW, when I do that at the command line, I get
> #error=setenv:command not found. if I replace #setenv by "set: I get
>no error, but the problem #still the same.
>Thank you, $inf{ USERNAME }, for submitting your comments. ;
>#end of /home/httpd/cgi-bin/query.pl
>
>The problem still:
>When I use my browser (Lynx), I get the expected entry:
>Enter your UserName:---------------
>But if I enter "spike" or anything in the blank space, There is absolutely
>no reaction.. no signal of interraction with the CGI-script.
>I made sure the ScriptAliases path in srm.conf pointed to the right
>CGI-bin path, I even tried <FORM METHOD="post"
>ACTION="home/httpd/cgi-bin/query.pl", and all posibilities in the <FORM>
>Tag, made sure the cgi-script was executable...still havent tasted the
>wonder of interacting CGI with my webserver.
>
>Thanks for Helping again,
>
>Marc
>
-- Charles Galpin <cgalpin@lighthouse-software.com>
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.