Posted to tcl by patthoyts at Thu Aug 24 15:28:10 GMT 2006view raw

  1. If you want a command line program that runs under Windows using tclsh and not wish then the following code in a .bat or .cmd file ensures tclsh gets lauched and evaluates the contents:
  2.  
  3. ::set HEADER { -*- tcl -*-
  4. @echo off
  5. echo %~0 %~f0
  6. if "%OS%" == "Windows_NT" goto WinNT
  7. tclsh "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  8. goto EOF
  9. :WinNT
  10. @rem this works for XP - probably not for 2k or NT
  11. tclsh %~f0 %*
  12. goto EOF
  13. }
  14. # --- cut here ---
  15.  
  16. foreach name [lsort [array names env]] {
  17. set spc [string repeat " " [expr {30 - [string length $name]}]]
  18. puts [concat $name $spc $env($name)]
  19. }
  20.  
  21. puts "$argv0 $argv"
  22. puts [info script]
  23.  
  24. # --- end ---
  25. # \
  26. :EOF