Although the installation of CGI programs highly depends on the web server, in this section we will provide some hints so that you can execute the programs described in this chapter on your web server. Clearly, your web server must be configured to enable the execution of CGI programs. Fortunately, most web servers support CGI programs, though they will likely require special configuring by the system administrator. A web server can be configured to interpret any file ending with “.cgi” and execute it when requested, or it can be also configured to execute only CGI programs stored in a particular directory, e.g., “cgi-bin”. Ask your system administrator for the instructions on CGI execution that are specific to your system.
In order to execute any web program written with the library HTML.Base, the helper programs curry-cpnsd (the Curry Port Name Server Demon), curry-cgi (managing and invoking CGI scripts written with HTML.Base), and curry-makecgi (compiling and installing a web program) are required. They can easily be installed by executing the following CPM commands (see also Section 5.2) on the web server (where PAKCS should be already installed):
> cypm install cpns > cypm install html-cgi > cypm install html
Now the installation of a CGI program is quite simple. Assume you have written a Curry program “myscript.curry” containing a definition of a form function “main” of type “IO HtmlForm” (see previous section). Then you can compile it into an executable CGI program by the command
> curry-makecgi myscript
This creates (after successful compilation) an executable program “myscript.cgi”. If your main form function has a name different from the default main, you can provide it with option “-m”. For instance, the command
> curry-makecgi -m myForm myscript
creates a CGI program with form function “myForm”. In general, the parameter following “-m” can be any Curry expression of type “IO HtmlForm”.88Since this expression is executed as the main program, all symbols of this expression must be exported from the Curry program.
Similarly, the option “-o” can be used to install the CGI program under a different name. For instance, the command
> curry-makecgi -o ~/cgi-bin/myscript.cgi -m myForm myscript
installs the executable CGI program in the file “~/cgi-bin/myscript.cgi”. Depending on the configuration of your web server, you can execute the CGI program by requesting the document with a URL like “http://your.server.name/cgi-bin/myscript.cgi” in your web browser.