#!/usr/local/bin/tclsh # # Copyright (c): Uwe Schmidt, FH Wedel # # You may study, modify and distribute this source code # FOR NON-COMMERCIAL PURPOSES ONLY. # This copyright message has to remain unchanged. # # Note that this document is provided 'as is', # WITHOUT WARRANTY of any kind either expressed or implied. #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" # $Id: test.cgi,v 1.2 2006-12-30 15:49:56 uwe Exp $ # Test Programm fuer das CGI Interface # ------------------------------------------------------------------------------ # # lade CGI Einlese und Dekodier Routinen source tcl/cgi-args.tcl # ------------------------------------------------------------------------------ # # format_cgi_args # bereite die Liste aller CGI Argumente auf # das eigentliche Einlesen und dekodieren # macht "get_cgi_argl" 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 } # ------------------------------------------------------------------------------ # # format_env # bereite alle Umgebungsvariablen auf proc format_env {} { global env set rs "" foreach i [lsort [array names env]] { append rs "env($i) = $env($i)\n" } return $rs } # ------------------------------------------------------------------------------ # # test_cgi_args # generiert eine Textseite # der Liste der cgi Parameter # dem Programmnamen des Skripts selbst # und allen Umgebungsvariablen 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] " } # ------------------------------------------------------------------------------ # # hier ist der Aufruf der Hauptfunktion # und die Ausgabe puts [test_cgi_args]