exec tclsh "$0" "$@"
source tcl/cgi-args.tcl
proc format_cgi_args {} {
set argl [get_cgi_argl]
set rs ""
foreach l $argl {
append rs [lindex $l 0] " = \"" [lindex $l 1] "\"\n"
}
return $rs
}
proc format_env {} {
global env
set rs ""
foreach i [lsort [array names env]] {
append rs "env($i) = $env($i)\n"
}
return $rs
}
proc test_cgi_args {} {
global cgi_argl cgi_argl_read cgi_input
global argv0 argv env
return "Content-type: text/plain
the pure query string
[get_cgi_input]
the cgi arguments
[format_cgi_args]
the global tcl variable
cgi_argl=$cgi_argl
the script name
argv0='$argv0'
the list of arguments
argv = '$argv'
the working directory
cwd='[pwd]'
the environment
[format_env]
"
}
puts [test_cgi_args]