|
Introduction All users with a UNIX account can use a portion of their available disk space to run CGI scripts to enhance their web pages. The steps outlined below will show you how to run and maintain CGI scripts on your UNIX account. All users who elect to use this service are responsible for the impact of their scripts on the University’s Computing servers. Specifically, the following types of scripts are not allowed:
Use of either type of script will result in a warning message. Only one warning message will be sent. Upon a second violation, your CGI access will be suspended. Users also assume all responsibility for damage inflicted via their CGIs. Support is not provided beyond basic setup questions addressed in this document and server-related problems. This document assumes you already have an active UNIX account and an understanding of basic UNIX commands. If you require additional information on accounts, see the "Accounts" section of the ITS web pages (see address above). For more information on basic UNIX commands, see the Quick Start titled "Common UNIX Commands" available in the "Documentation" section of the ITS web pages.
Creating a CGI Directory in Your Account with "startcgi" To create your CGI directory, type startcgi at the command prompt from your home directory. This script creates a public_cgi subdirectory where your CGIs will be stored. (You need only to run this command once.)
Creating a Sample CGI All CGI scripts must be placed in your public_cgi directory and named with a ".cgi" file extension. (Our CGI server will only recognize scripts that end with ".cgi" — i.e. not .pl or .exe...) In the example below, you will create a very basic script called "hello.cgi". Using the "pico" text editor (pico is a good editor for beginners), you will create a script which will simply print the words "Hello World!" in your browser window. To create this sample CGI, follow the instructions below.
You should now be back to the UNIX command line prompt.
Making Your Script Accessible with "setcgi" To allow web browsers to view any newly created or uploaded CGI scripts, you must type setcgi at the command prompt. The setcgi command descends the public_cgi directory, if it exists, and sets the appropriate file permissions on the public_cgi directory and any subdirectories so that your CGIs will function properly.
Linking to Your CGI’s Provided that you have followed the steps above properly, you can link to your scripts from a web browser by using the following address format: http://cgi.albany.edu/~your_userid/script_name.cgi For example: http://cgi.albany.edu/~ab1234/hello.cgi Please remember: 1. Any time you add new scripts to your public_cgi directory, you must remember to run setcgi. 2. CGI scripts may only be linked to from albany.edu domain sites. 3. In order for scripts to execute properly they must be have a ".cgi" file extension.
Transferring CGI’s to a UNIX account If you have already created CGI scripts and wish to move the files to your account via an Internet connection, please see the Quick Start titled "Using WS_FTP". (Note: You will still need to upload these files to the public_cgi directory on your account and then set the permissions appropriately by using the setcgi command.)
Writing/Securing CGI scripts All CGI scripts are executed under the owner’s userid. Therefore, any script that you use will have access to all files and directories that your account has access to, and have the potential to modify or send messages in your name. With this in mind, security is an important issue when dealing with CGI scripts. Although it is difficult to guarantee that a script is entirely safe, it is important to examine scripts and understand their functionality. If you do not understand the language that a script is written in or do not understand exactly what the script does, you should not use it. Accordingly, you should be conscious of the following when writing or securing a CGI script.
CGI Creation Summary
Resources for Writing CGI Scripts Additional resources for writing CGI scripts are available at: http://www.albany.edu/its/web/webresources.html Information Technology Services Helpdesk, LC-27 Submit an ITS Service Desk Request at: http://www.albany.edu/its/help |