The University of Tennessee
A-Z Index  /  WebMail  /  Dept. Directory

Office of Information Technology

Search OIT    Contact Us    Site Map    Policies   

OIT Support Lines 8:00AM - 5:00PM Monday-Friday
Phone: (865) 974-9900
Walk-in Consulting in The Commons - Helpdesk Contact Form


WWW Help

Creating and Using CGI Scripts

Introduction
CGI services on web.utk.edu are made possible by a software package called cgiwrap. This package allows individual users to create and user their own CGI scripts while enforcing higher security. Cgiwrap was written by Nathan Neulinger at Missouri Technological University.

CGI scripts are used to handle output from World Wide Web forms, but can also be used for pretty much any task that you want to be able to initiate from a WWW client, such as Netscape, Internet Explorer, Mosaic, or Lynx.

Information on Deploying CGI

  • Setting Up And Using CGI

  • Sample CGI on web.utk.edu

  • Scripts You Can Already Use

  • Where to Go For CGI Scripts

  • Server Side Includes (SSI) -- DII's web servers support Server Side Includes (SSI). There is however, no support for creating or debugging your scripts. Please do not contact the DII Help Desk or NTUSG for help in debugging or writing your scripts. This link will provide you with links to a host of documents on how to use SSI. Happy scripting. This SSI tutorial may also be of some help.

  • Java Servlets -- NTUSG does not currently support Java Servlets on the web.utk.edu web server.

  • PHP: Hypertext Preprocessor -- PHP is a server-side HTML-embedded scripting language. NTUSG does not currently support PHP on the web.utk.edu web server.


Setting Up And Using CGI

Introduction
First you must have set up your UNIX account for a WWW home page. If not first do so and then follow these instructions.

Create The Proper Directories

First create the directories needed to hold the CGI scripts by issuing the following commands:


  cd
  cd public_html
 mkdir cgi-bin


Only this directory name will work.

Set Permissions

In order for people to use that directory access will have to be granted. This is done with the following command:


 chmod 755 cgi-bin


This grants all users read and execute rights to your cgi-bin directory.

Installing Scripts

Copy all the CGI scripts into the cgi-bin directory. Then set the proper permissions on the script by issuing the following command:


 chmod 755 some-script.cgi


CGI scripts can end in .cgi, .pl, or nothing at all.

Using the Scripts

To execute the script you include it one of three ways:

http://web.utk.edu/cgi-bin/cgiwrap/username/some-script.cgi
http://web.utk.edu/cgi-bin/cgiwrap/~username/some-script.cgi
http://web.utk.edu/cgi-bin/cgiwrap?user=username&script=some-script.cgi

Debugging Scripts

To debug a script with cgiwrap just add a d in the script call line:

http://web.utk.edu/cgi-bin/cgiwrapd/username/some-script.cgi

Common Errors with CGI

Probably the number one reasons for CGI or Perl Scripts not running on web.utk.edu is the very first line of the script. Most perl scripts come with the first line looking like:

#!/usr/bin/perl than needs to be changed to #!/soft/script/bin/perl

The second largest error on CGI scripts is incorrect permissions. Always read through the README file that comes with the script to correctly set the permissions.

Back to Top

 


Sample CGI on web.utk.edu

The Code

Sample HTML Page

CGI Script &ReadParse;&PrintHeader;

Download "cgi-lib.pl" Rename The File To "cgi-bin.pl" not "cgi-bin.perl"

Back to Top

 


How To Use The Public Scripts

The public form handler script emails you the form a user fills out on the web. If an email address is specified by the user a confirmation of the entered data is sent back to them. If you wish a different message for each form can be attached to this email.

When the user submits the form, the script displays a generic thanks page. You can override this, and design your own HTML thanks page with all the usual web page design elements that you'd like to use. Or you can redirect to any page on the Web.

NTUSGe
The "action=" part of your form must look like this,
<FORM METHOD="POST" ACTION="http://web.utk.edu/cgi-bin/form.cgi">

Mailing Data
Put your email address in so the completed form will be emailed to you by:


<INPUT TYPE="hidden" NAME="to" VALUE="username@utk.edu">

Subject
You can specify the title of your email by:


<INPUT TYPE="hidden" NAME="subject" VALUE="The Email Subject">

Required Field
To check and see if the user has filled out certain fields you add something like:


<INPUT TYPE="hidden" NAME="Required" VALUE="last_name,first_name,email">

Response Message
To add a message to the user along with what he filled out add a line like:


<INPUT TYPE="hidden" NAME="BlurbFilePath" VALUE="/something/extra.txt">

Return Link/Title
To change the Generic return link and title you can add the lines:


<INPUT TYPE="hidden" NAME="ReturnLinkURL" VALUE="http://web.utk.edu">
<INPUT TYPE="hidden" NAME="ReturnLinkTitle" VALUE="Home Page">

Custom Thank You Page
The display a different thank you page create it and add this line pointing to that file


<INPUT TYPE="hidden" NAME="EchoFilePath" VALUE="/homearea/public_html/thanks.html">


If you'd like to display the user data on your custom page include the line


<!--ECHO DATA HERE-->


somewhere in your page coding.

Redirect To Another Page
To redirect the user after filling out the form include the line:


<INPUT TYPE="hidden" NAME="RedirectURL" VALUE="http://www.utk.edu">

A Sample Form Page Would Look Like

Back to Top

 


Where To Go For CGI Scripts

Matt's Script Archive
http://www.worldwidemart.com/scripts

Script Search
http://www.scriptsearch.com

Selena Sol's Script Archive
http://www.extropia.com/index.html

The Ultimate CGI BIN
http://tucb.com

Back to Top