Generate Custom HTML Reports Using CGI Tutorial

Every vovserver has a built-in HTTP interface, which includes the ability to quickly generate customized reports using the CGI (Common-Gateway-Interface) mechanism. This tutorial guides you through the first simple CGI script.

You will write a CGI script that is project specific, and install it in the cgi subdirectory of the server configuration directory:
% set cgidir = `vovserverdir -p cgi`
% echo $cgidir
/home/someuser/vov/test.swd/cgi # Or similar
% mkdir  $cgidir
% cd  $cgidir
% vi tutorial.cgi
File tutorial.cgi
#!/bin/csh -f
# The rest is -*- Tcl -*-  exec vovsh -f $0 $*

# This is file tutorial.cgi

    HEAD { TITLE "CGI Tutorial" }
    BODY {
        OUT "Hello World"

The first 3 lines are a common UNIX technique to make this script executable by vovsh, which is the main FlowTracer client. Notice that this script is written in Tcl syntax.

The commands VOVHTML_START and VOVHTML_FINISH are required.

The procedures HTML, HEAD, BODY, and OUT, are defined in the file $VOVDIR/tcl/vtcl/vovhtmlgen.html and are a convenient way to generate well formed HTML code. You are not required to write the CGI script in Tcl, only we believe you will find it extremely more convenient to do, especially considering that the FlowTracer API is itself in Tcl.

To satisfy the curious, here is how the same script could have been written without Tcl.

#!/bin/csh -f

# This is the hard way to write a CGI script.
echo "\r"                # Important empty line!
echo "<html>"
echo "<head><title>CGI Tutorial</title></head>"
echo "<body>Hello World</body>"
echo "</html>"
exit 0
Make the script executable and use a browser to visit the URL given to you by the command vovbrowser.
% chmod a+x tutorial.cgi
% vovbrowser -url /cgi/tutorial.cgi