Skip to Content

CGIwithoutprogramming

Simple CGI without programming.

Wilhelmus J. Geerts

Department of Physics, Southwest Texas State University, San Marcos, TX78666

phone: 512-245-1821; fax: 512-245-8233; e-mail: wjgeerts@txstate.edu

 

The Developed Software is public domain and is available upon request

There are several ways to make web pages interactive. The two most frequently used methods are:

  • the inclusion of small Java-script programs on the web pages.
  • the use of small common gateway interface (=cgi) programs on the web server.

The first method is a very fast technique as those programs run at the client computer (=the web browser with which you download the web pages). Another large advantage of Java-script is that it is easy to learn for people who know how to author web pages. For simple applications a thirty dollar investment [1] and two Sunday afternoons will get you started smoothly. For more serious applications I recommend you to go with a more solid reference work as for example [2]. Unfortunately not all browsers understand the Javascript-language. If you stick to the latest versions of Netscape Communicator and Microsoft Internet Explorer and only use Javascript 1.2 commands you can be pretty sure that your application will work flawlessly. Be careful as earlier versions of both browsers contain several bugs in the way they interpret the Javascript commands. As the small Javascript programs are included in the HTML, they can be viewed by the user and believe me you do not need a degree in computer engineering to modify a web-page. This makes this method less suitable for tasks as for example on-line quizzes, grade-books, or other jobs where confidentiality is an issue.

The second method uses small CGI-programs on the server which communicate with your web browser. This method is much more secure as it is not possible for a user to view or modify the code of those programs. As there is more communication between the server and the browser, the web site will become slower. Its speed will depend mainly on the speed of the network. The CGI-programs are normally written in Perl, Visual Basic, Pascal, C, or C++. Although whole books have been written about advantages of one language over the other, the way to go is to choose a computer language you already know. If you are not a super computer-wiz, you need to look for a program library with CGI-functions and procedure. For almost all computer languages libraries exist. More details can be found in for example [3]. Furthermore you need a compiler that translates your source code in executable program which you can put on your server. The whole process of writing, debugging, compiling, and testing cgi-programs can be quite complicated even for people with programming experience.

In order to simplify the process of designing interactive web sites based on the CGI technique, I wrote a small program which extends the HTML language with some simple commands. This program needs to be installed on the web server and will enable the web designer to generate CGI-type interactive web sites without CGI-programming. More details on the syntax are given below. A beta version of the program is available for SWT employees. Double_u is written in C and makes use makes use of Thomas Boutell’s cgic library, which is free for non-commercial use. You can use Double_u as is, I’m not responsible for any consequences caused by it.

CGI without programming:

  1. Put the program double_u.exe in the cgi-bin folder of your web site.
  2. When designing a form start with the following two lines:
  3. <FORM METHOD="post" ACTION="{replace this by the URL of double_u.exe">
    <INPUT TYPE="hidden" NAME="url" VALUE="{replace this by the response file name}">
    The location of the response file should be defined with respect to the root web folder. So if the response file is in the root web folder, it should be identified without a path name.
  4. The response file name is a normal web page which in addition to the HTML and the javascript can contain other commands. These other commands are interpreted by the double_u program and removed before the web server will send the response page back to the client. All double_u commands should be placed between <qwjma> and </qwjma> tags. Those tags can only be used in the body of the HTML document. They can not be used within <script> tags.
  5. You have to define the elements of the submitted form to double_u.exe. You can do this with the following command:
    define:parameter_name:parameter_type:parameter_length
    parameter_name is the name of the form element on the page which calls double_u
    parameter_type is the type of that form element. At the moment double_u only recognizes text and textarea. The maximum number of characters for text is 30 and for textarea is 500. Characters beyond these numbers will not be displayed or stored.
    parameter_length is the total length of the form element.
    After defining the elements of the form which you want to have available you can use the following double_u commands:
    • print:
    • parameter_name
      In which parameter_name is one of the defined form elements, or time, or date.
    • read:
    • file_name
      If file_name can be a defined parameter_name or an arbitrary string. Double_u will include the file <content of file_name>.htm or file_name.htm in the document returned to the client.
    • write:
    • file_name:parameter_name_1:parameter_name_2 .....:parameter_name_i
      The contents of parameter_name_1, parameter_name_2, ..., parameter_name_i will be appended to the file identified by file_name. For the syntax of file_name the same rules apply as to the file_name of the read command. In addition to one of the defined parameters, parameter_name can be time or date.
      The exact location of the files of the read and write command can be specified with the path command. Its syntax is:
    • path:
    • path_name
      The path_name is the name with respect to the root folder of your web site. It is possible to use this commands several time on one page.

    Remember that all double_u commands have to be placed between the <qwjma> and </qwjma> tags. Do not put them in the header as most HTML-editors do not like that.

References:
[1] JavaScript for Dummies, Emily A. Vander Veer, 0-7645-0223-9.
[2] Javascript, The Definitive Guide, David Flanagan, 1999, 1-56592-392-8.
[3] Sam’s teach yourself CGI Programming in a Week, Rafe Colburn, 1998, 0-57521-381-8.