Version 0 of exec ampersand problem

Updated 2002-10-11 10:34:48

The exec command treats ampersands in its arguments specially, e.g. for making execution asynchronous. This can be a problem if an argument, like an URL, contains ampersamds.

[email protected] (Petteri K) writes in the comp.lang-tcl newsgroup:

 Would anybody know a workaround in case $url contains
 character '&' e.g. 
 http://127.0.0.1/cgi-bin/script?var1=abc&var2=xyz

Benjamin Riefenstahl replied: exec plays tricks with quoting which make it impossible for me to get the right command executed in Tcl 8.3.4. What works on W2K here though is this:

   set url "http://www.tcl.tk?hello&hi"
   set shell [open "|[file join $env(COMSPEC)]" w]
   fconfigure $shell -buffering line
   puts $shell "start \"\" \"$url\""
   puts $shell exit
   close $shell

I hope this works on Windows 9x/Me, too.