Hey, show me how to do a script that wakes up at set times

Ok, here it is: ANS.txt

What about a piece of code that does async socket connection handling but which would only make sense to MattWalsh?

You asked for it: TCLsocket.txt

Hey, I need those various socket routines referenced in the above script...

Take them: IPPROCtcl.txt

How do I process stdin in a CGI script?

proc getStdIn {} {
   global env
   global stdinVars

   set envvars {SERVER_SOFTWARE SERVER_NAME GATEWAY_INTERFACE SERVER_PROTOCOL SERVER_PORT REQUEST_METHOD PATH_INFO PATH_TRANSLATED SCRIPT_NAME QUERY_STRING REMOTE_HOST REMOTE_ADDR REMOTE_USER AUTH_TYPE CONTENT_TYPE CONTENT_LENGTH HTTP_ACCEPT}

   if { [info exists env(CONTENT_LENGTH)] } {
      set message [split [read stdin $env(CONTENT_LENGTH)] &]
   } else {
      return 0
   }

   if { $env(CONTENT_LENGTH) == 0 } { return 0 }
   foreach pair $message {
      set name [lindex [split $pair =] 0]
      set val [lindex [split $pair =] 1]

   #filter out evil characters...
      regsub -all {\+}   $val { } val
      regsub -all {\%0A} $val \n\t val  
      regsub -all {\%2C} $val {,} val   
      regsub -all {\%27} $val {"'"} val
      regsub -all {"`"} $val {"e"} val
      set stdinVars($name) $val
   }   
}

How to recursively get all the files in a directory

global counter

proc getFilesInDir { dirname } {
   global counter
   set s [glob -nocomplain "$dirname/*"]
   foreach thisOne $s {
      if {[file isdirectory $thisOne]} {
         getFilesInDir $thisOne
      } else {
         puts "$thisOne"
      }
   }
   puts $dirname
}

set counter 0
getFilesInDir [pwd]

-- MattWalsh - 08 Jan 2002

Topic attachments
I Attachment Action Size Date Who Comment
Texttxt TCLsocket.txt manage 2.9 K 06 Aug 2002 - 00:17 MattWalsh  
Topic revision: r1 - 08 Jan 2002 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback