NOTE: the following write up, though interesting, is no longer true as of Jan 31 1995. I changed the phonebook form to be less Byzantine in operation, relying on local DB-Lib on the WWW server rather than the 3-way connection described below. The result is a little slower to return an answer (since it has to connect to the dataserver each time) and does not provide as much logging, but also relies only on two machine being up rather than three and hence is more robust. The rest of what you read here is still true -- that is, it's still Tcl and it's still very simple.

How does the PhoneBook form work, really?

I got the campus phone book as a flat file from CATS. I built a Sybase table and loaded the data from the flat file into it. The phonebook that I was given, which is now several months old, now resides on my admin Sybase server (abacus). That was Step 1. IMHO the phone book should be residing on Data Warehouse, and should be updated continually, not once a quarter or whatever the ritual is now.

I have Tcl-DP, a Tcl extension which enables the programmer to write RPC-based apps in Tcl. Using DP and Tcl/Tk, and the sybtcl extension, I wrote a little daemon called queryServer, which can submit a SQL query to a server (abacus, for example) and send the results back to a remote client. It's a beta test application at this point, with a live X11 control panel that tells me about who is running it and what queries they are making. It runs on helios (these days). It would be trivial to put up a production version with no X11 client, that could be started from rc.local.

The reason for all that was to prove that a Unix host without Sybase DBLib or any other commercial product on it could submit a SQL query via this daemon and get an answer. Regardless of host architecture. Any host where Tcl-DP can be built will work. Tcl/Tk and all its extensions are free, so essentially this removes the licensing problem, and the non-availability of DBLib for, oh, Linux, for example.

So far so good... Now, on the www server (ucowww) we put a www form with a fill-in blank and some pushbuttons for the user to play with. That form invokes a cgi exe (written in Tcl) which knows how to open an RPC connection to the host where the queryServer daemon is running. It constructs a SQL query based on the user's use of the form, and submits that query. It gets the answer, which consists of N lines of text, and formats that into the results page which replaces the form page after execution.

For those who would like to write their CGI scripts in Tcl, here is the boilerplate Tcl code for parsing the args from the http form (boilerplate courtesy of Bob Jackson at StScI, thank you Bob!

So any user with a mosaic client (sitting at a mac or pc or sun or anything else you can think of that will talk to the Web) can query the campus phonebook via a simple, intuitive form. The Webserver does not have to have DB Lib, it only needs to talk to some host that does have DB Lib, and the hosts need not be of like architecture. The host with DB Lib need not be of like architecture with the Sybase host.

Since ucowww happens to be itself yet another Sybase server, I could have spared a certain amount of overhead by doing everything locally instead of involving two other hosts just to get the data. However, this was done to prove a point, not to save cpu cycles.

The queryServer and CGI exe could have been written in some other language, Or the CGI could have been written in one language and the queryServer in another; as long as the RPC mechanism is used, who cares? But Tcl is the speediest language I know of for putting something like this together. I wrote queryServer in about 1 day, and the phone book www page in less than 2 hours (complete). It took me longer to write this page than to write the cgi exe for the form.