Testing a script
This form uses this
perl script
to interpret the information from the user. The perl script should be
placed
in a cgi-bin directory. The copy linked to from this page is only so
that you can see it or download a copy for your own use.
The script was posted to the net by S.E.Brenner@bioc.cam.ac.uk,
and contains its own copyright statement.
Test script using a form to collect information
Test script without a form
If you don't want to use a form, you can use the
get method which puts a fixed
query in the link
that causes the script to be invoked.
Next Steps
If you wish to develop a cgi-script in the Computing Science department
at Newcastle, you must first contact
webmaster.cs@ncl.ac.uk to
ask for the necessary configuration changes. This will normally only be granted if:
-
You are studying one or more computing science modules ; and
-
you need this facility for part of your course work (rather than for
personal use).
There are a few common errors that you should be careful to avoid:-
- If you write some perl which contains a
syntax error, and to access this without checking for syntax errors
first. On the web, you are simply told that the script ran but returned
no data when this happens. Please check that the script compiles by
running it outside the web first, even if you cannot provide the
correct input data that way. Although there are no guarantees, if a
script fails to run, the web server has been configured to return a
form offering to show you the last few lines of the error
logs, in case this is any help.
- Please remember that the perl interpretor is not always in the
same directory. On pontop it is in /usr/local/bin, so your perl script
needs to start with
#!/usr/local/bin/perl
- If writing any sort of compiled program, note that pontop is not
running linux. You must compile your program or perl module on pontop
itself, or on burnhope.
- If writing C++ cgi-bin programs, you MAY need to compile them with
a -R flag specifying a directory name to search for shared library at
runtime. Try running your program on pontop directly, and if this
fails run
ldd your-program-name
.
If this shows unresolved
libraries, such as libstdc++.a then adding
-R /usr/local/lib
to your compile line should help.
- You can't put your scripts or programs in a sub directory of your cgi-bin.
With the current set-up in this department, you cannot do this.
For example:
http://www.cs.ncl.ac.uk/people/c.r.ritson/cgi-bin/sub/script.cgi?Field1=One
is split into four parts:
- The first part
http://www.cs.ncl.ac.uk/people/c.r.ritson/cgi-bin
is used to indicate to the server that a program is to be executed and
its output returned. This is set up on a per-user basis.
- The next single path name componant
sub
is
taken to be the name of the program to be executed.
- The rest of the path name
script.cgi
is passed to this script
via its PATH_INFO environment variable.
- Finally, this example contains a parameter,
Field1=One&Field2=Two
which is also passed in to the script.
webmaster.cs@ncl.ac.uk 7th September 1995 .. 13th October 2000 ...