Although the installation of CGI programs highly depends on the web server, this section provides 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 Curry-to-CGI compiler curry2cgi is required. It can easily be installed by executing the following CPM command (see also Section 5.2) on the web server (where PAKCS should be already installed):
> cypm install html2
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 HtmlPage” (see previous section). Then you can compile it into an executable CGI program by the command
> curry2cgi 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 specify it with option “-m”. For instance, the command
> curry2cgi -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 HtmlPage”.22 2 Since 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.