CSCI-4220 Network Programming

Project 4 - CGI TODO List manager
Frequently Asked Questions

Q:The web server won't run my program!

A:Make sure the name ends in .cgi, and that the permissions are correct.

Q: Help - I can't get file locking to work!

A:Don't bother with (fcntl based) file locking, it won't work on the filesystem holding your home directory.

Q: I keep getting errors back from the web server - it doesn't look like my CGI program is ever run.

A: First - check the permissions, make sure your progam is readable and executable by anyone, but not writeable by group or other.

In general, you can find out what is happening by looking at the log file for the web server - the logs files are in /usr/local/www/logs/machinename/. The file access_log contains one line for each (successfull) request and the file error_log contains information on failures. These files may be quite large - you can use the unix tail command to look at just the last few lines or use grep yourname error_log to look at all lines that include URLs with your username in them.

Q: How do I lock/unlock a file?

A: Use fcntl. There is some sample file locking code here (check the file lock.c).

Q:I read the project 4, but I still don't have concret idea about what TODO list manager is, what we can get from such server. Could you again give us a list of steps required to make a TODO list manager?

A: A TODO list is a list of items (each can be a text string). For this project I've asked you to also keep track of the date entered for each item. For example, here is my TODO list for Spring Break:

ItemDate Created
Grade TestThu Mar 4 14:21:45 EST 1999
Grade Project 3Mon Mar 1 06:13:01 EST 1999
Think about stuffSat Mar 6 09:11:03 EST 1999
Eat CookiesSat Mar 6 09:11:03 EST 1999
Your CGI proram must be able to display a user's current list, to add new items to the list, and to delete items from the list. You must support multiple users, so you need to have some kind of a logon screen - you can check out the pizza server CGI programs for examples:
Using hidden fields: Code Test it available on the CS machines in the directory
~hollingd/public.html/netprog/code/CGI/pizza
Using cookies: Code Test it available on the CS machines in the directory
~hollingd/public.html/netprog/code/CGI/pizzacookie
Here is a list of steps that might be useful in your development:
  • Create a CGI program that can send back an HTML version of a TODO list (read from disk).
  • Create a CGI program (or add to the above program) that can add a new item to a TODO list and update the list saved in a file.
  • Create a CGI program (or add to the above program) that can delete an item from to a TODO list and update the list saved in a file. It is required that you allow users to delete items by clicking or selecting, that is - the user should not have to type in the text of a TODO list item to delete it.
  • Modify the above program(s) so that they can operate on a TODO list stored in a file that corresponds to a specific user name. You can also have a single TODO list containing entries for multiple users, although you then need to extract a single user's items when asked for a list.
  • Create (or add to the above program) a logon screen that establishes the user's name. This information must somehow be propogated to future requests (using hidden fields or cookies) so that each time the CGI is run it knows what the user's name is.
The Pizza server program(s) are examples of a single CGI program that can do more than a single function - the one progam handles logon screens and pizza orders. In general I think this makes it easier to develop, instead of 4 or 5 programs you just have one.