Write CGI Scripts
These are guidelines for writing cgiscripts to work with vov.
The script must generate a legal HTTP reply, taking into account that VOV already
provides the first line which is always
HTTP/1.0 200 OK
Typically, the script must begin by printing to stdout the following data:
Content-Type: text/html
Content-Length: the length of the HTML page
<<-- Will not work without this empty line!!
The content of the HTML page
This task is greatly simplified by:
- writing the CGI script as a Tcl script;
- taking advantage of the procedures defined in VOVDIR/tcl/vtcl/vovhtmlgen.tcl.
Simplest CGI script
#!/bin/csh -f
# The rest is -*- Tcl -*- \
exec vovsh -f $0 $*
# Try this by means of the URL /cgi/ciaobello.cgi
VOVHTML_START
HTML {
HEAD { TITLE "Ciao bello example" }
BODY {
OUT "CIAO BELLO"
}
}
VOVHTML_FINISH
Retrieving VOV information
You can use the vtk
library to get information from the
trace. Here is a simple example, that also shows a way to generate tables.
#!/bin/csh -f
# The rest is -*- Tcl -*- \
exec vovsh -f $0 $*
# This script responds to a URL of type: /cgi/getnode.cgi?nodeid
set id [shift]
VOVHTML_START
HTML {
HEAD { TITLE "Get Node $id" }
BODY {
H1 { OUT "Node $id" }
set nodeInfo [vtk_node_get $id]
TABLE {
foreach field { status barrier timestamp type } {
TR {
TH { OUT $field }
TD { OUT [shift nodeInfo] }
}
}
}
OUT "CIAO BELLO"
}
}
VOVHTML_FINISH