NYU Database Systems (Spring'2000)

Developing and Installing CGI programs

CGI (or Common Gateway Interface) is a common method for the browsers to send data in web forms to the web servers, where the data is passed to a program (specified within the page) for execution. The screen output of that program is displayed back at the browser.

As simple as that.

You got help!

The following references list various HTML and Form elements that can be used in your web page. Use any text editor for creating the page (or even a page creation tool).

CGI details can be found here:

CGILIB: CGI programs need to extract the form values from an environment variable called QUERY_STRING. You can do this yourselves, or use any library of routines written by others. I have collected one such library from the web, called, libcgi.a, which you are welcome to link with and use in your assignment and project. How? (this will work directly with C programs, if you are writing C++, you need to change cgi.h a little bit)

Installing and Invoking CGI Programs at NYU SUN Machines:

You will need to do Steps 1-3 only once; Do Step 4 every time you create a new version of the cgi executable program. Step 5 & 6 are done when you are creating the web page.

  1. Create a directory called "public_html" in your home directory. (mkdir public_html)
  2. Create a cgi-bin directory within public_html (mkdir public_html/cgi-bin -- from your home directory)
  3. Give public read and execute permissions to both directories (and for any files you may keep within later) (chmod -R 755 public_html)
  4. Copy your executable CGI program, and any data files it may need, to the cgi-bin directory. (make sure that it has the read/exec permissions set by doing "ls -l")
  5. If this program is called, say, "test", then the corresponding URL for invoking this program from the web page is: http://cs1.cs.nyu.edu/cgi-bin/cgiwrap/user/test (user is your login name on the sun machines)
  6. Store your HTML files (web pages) in the public_html directory (or a sub-directory within).


For illustration, I have created a web page and a cgi program (test.c); check it out for getting started.

Web Page

URL of CGI Program invoked in response: http://cs1.cs.nyu.edu/cgi-bin/cgiwrap/poosala/test

Source code for test.c

Source code for test.cc (C++ version)

Any questions -- contact the TAs or me.

Vishy Poosala. 1/26/2000

Back to Course Home Page