Note: this explanation you have the PERL script language installed and that you are on a unix-like system.
Ok: there are two steps you need to complete in order to use the script on your machine.
which perl
at a Unix prompt.
% which perl /usr/local/bin/perlThis path must be hard coded into the first line of the script so it also matches the output of the
which perl
command:
#! /usr/local/bin/perl # # Mogens Sept 94 etc etc...That is important. The next step is to make sure that the file is executable, so type
% chmod a+rx comment.perl % rehash % ./comments.perl Location: /default-comments.html Content-type: text/html The comments are <A HREF="/default-comments.html">here</A> <P> %Ok - you now need to place the comments.perl into the cgi-bin directory, or (if you are using the NCSA server) make sure the .perl suffix is associated with the
application/x-httpd-cgi
- check the end of the server's
conf/srm.conf file.
As a final check we can access it through the web server by using the proper
http://your.machine-name.domain/cgi-bin/comments.perl
.
The program should respond with a link to a non-existent file called
default-comments.html
.
First locate the # Define fairly constants
section.
Change these three lines:
$COMMENT= "/usr/local/etc/httpd/htdocs/default-comments.html"; $URL="/default-comments.html"; $SENDMAIL="/usr/lib/sendmail -t";
sendmail
on your system and put it in this variable.
You can try typing which sendmail
or asking your admin.
realname - text
Full name of submitter - defaults to 'Anonymous'
username - text
e-mail address of submitter.
comments - TextArea
comments to be added
mailto - hidden
e-mail address to CC new comments to - none.
The other piece of information is to note that the path info (excess path when referring to the script) is used to point to the file that is used for storing comments. Since that made no sense, let's illustrate with an example.
Ok - we have the partial URL path
/cgi-bin/comments
which refers to the
comment script.
We can extend this path and have the server pass the
extra information to the script.
We also have the comments file located at URL /foo/chatter.html
.
We add the partial URL of the file to the script URL to get:
/cgi-bin/comments/foo/chatter.html
.
What happens is that the /cgi-bin/comments
script is run, and the
excess /foo/chatter.html
is passed to the script as extra
information. This is important, because it allows us to have many different
comment files without having more than one script.
/cgi-bin/comments runs the script without any path info. /cgi-bin/comments/foo runs the script with /foo as path info. /cgi-bin/comments/a/b/c/ runs the script with /a/b/c/ as path info.
<FORM ACTION="/cgi-bin/comments/foo/chatter.html" METHOD="POST"> Name : <INPUT NAME="realname"> E-mail : <INPUT NAME="username" MAXLENGTH=40> Chat : <TEXTAREA NAME="comments" ROWS=6 COLS=40>Chat here</TEXTAREA> <INPUT NAME="mailto" TYPE="hidden" VALUE="mogens@cs.stanford.edu"> </FORM>Now for the clever bit.
/foo/chatter.html
to the
script. The script then appends the comment to the file /foo/chatter.html
.
Now, if the /foo/chatter.html
file contains the form (and is
world writeable so the server can access it), then the comments are
placed after the FORM. Simplicity itself.
In order to make a file writeable by anyone (world writeable) use
% chmod a+rw foo.html % ls -l foo.html -rw-rw-rw- 1 mogens users 159 Aug 26 19:21 foo.html %
So to summarise: