CGI
Scripts
- Scripts must be made
executable by typing "chmod 755
filename" after logging in.
- Any script must end in .cgi to
ensure execution.
- Scripts that dont respond with
Content Type tag as first LIne, must be named
nph-Scriptname.cgi . The nph- stands for
non-parsed-headers.
- Perl 5 is located at
/usr/bin/perl make sure the first line has this
right or else!
- Perl 4 scripts usually will
need to have any @ or $ escaped with \ character
to be perl 5 compatible. ie print
"webmaster\@yourdomain.com"
- The directory cgi-bin is
reserved for our shared cgi directory. You can
use a directory other than cgi-bin or icons to
store your scripts. Actually the cgi-bin is
mapped to our /usr/local/www/cgi-bin/ so you can
use our cgi scripts with your domain.com and not
have to make duplicate copies of the files.
- index.cgi is valid, as a
directories home page for a cgi script. Like wise
you could replace index.htm with index.shtml to
use PARSE(Servier Side includes).
- <!-- Server Side includes
--> only work in files with .shtml extension.
The execute bit and read public bits must be on
to use .shtml.
- <!--exec
cgi="mycgi.cgi" --> is a cool way to
output the result of a simple cgi script into the
middle of somefile.shtml .
- If you can't figure out why it
doesn't work , run it from the command line, or
rename it to nph-Scriptname. You'll see more
error messages.
- CGI is programming, don't be
mistaken into thinking it is as easy as HTML. You
might want to try a consultant.
- If you are going to use perl ,
buy a Perl book, please.
- If you can't figure it out,
ask us, we will help you by email on a time
permits basis.
My First CGI
SCRIPT - myfirst.cgi
#!/bin/sh
echo Content-type: text/plain
echo
echo 10 print "HELLO"
echo 20 goto 10
echo Hello there I see you saw my page at $HTTP_REFERER
echo You are using $HTTP_USER_AGENT as a browser.
echo $HTTP_USER_AGENT >> agentfile.txt
echo \<a href=\"http://mydomain.com\"\> Home \</a\>
Yawn - Notice the \ escapes, the
blank echo after the content-type line. Also If you want
to use agentfile.txt line, i had to upload a blank file
called agentfile.txt, and then use the file manager to
set PUBLIC WRITE on that file. Or the script will not
work! (telnet: touch agentfile.txt;chmod o+w
agentfile.txt)
Helpful links
Matt's Script Archive
- A great collection of miny perl scripts that are free
to use. This site is highly recommended if you are just
beginning to learn perl and CGI.
Basic Procedure for Executing a Perl Script
from a WebPage
- A basic, and helpful, tutorial on how to set-up a CGI
script- using a 'counter' as an example
Galaxy's CGI- Common Gateway
Interface
- Lots of information on CGI scripting, and the longest
URL on the Web, including pointers for more information
on image mapping, etc.
O'Reilly
& Associates
- Don't normally recommend books, but in the case of
Perl, Unix, Linux, Scripting, etc. your might need to
read-up with the best.
The Common Gateway Interface
- An introduction (with examples) to CGI scripting. One
of the best sites.
The processing of CGI arguments under TCL
- More information on CGI.
Imagemap
Help Page
- Imagemaping made simple in an easy to follow guide.
HTGREP
- if you need a searchable index, this is supposed to do
the trick. I haven't messed with it yet, though.
NASA's 'Information on Search Tools'
- a interesting page with many ideas on solving local
searching problems.
PERL
- A great language to learn in the generation of dynamic
documents (on-the-fly page creation) such as forms.
|