Why can't exec run Tcl scripts?Probably because the skript is not an executable?
This works and it opens wordpad on Windows:
% package req Tk
% set f [tk_getOpenFile]
C:/Program Files (x86)/Windows NT/Accessories/wordpad.exe
% exec $f
But if I choose a Tcl script in the file selection dialog, then exec
throws an error:
% exec $f
couldn't execute "C:\blah\blah\blah.tcl": no such file or directory
Weird thing is that exec seems to have changed forward slashes to
backward slashes during this process. It doesn't matter if I add a
shebang line at the top the Tcl script files. It complains either way. Putting the file $f in a list doesn't change the outcome.
Why can't exec run Tcl scripts?
Because winblows is not a Linux/Unix system. exec passes whatever you
give it off to the OS, and if the OS does not know how to "run" a tcl
script (and winblows does not unless you have configured it to know
how) then the OS cannot run the script.
Am 06.03.2026 um 18:11 schrieb saito:
Probably because the skript is not an executable?
Why can't exec run Tcl scripts?
It will work if you execute wish.exe along with the script name as a
command line argument.
On 3/6/2026 1:23 PM, Rich wrote:
Because winblows is not a Linux/Unix system. exec passes whatever you
give it off to the OS, and if the OS does not know how to "run" a tcl
script (and winblows does not unless you have configured it to know
how) then the OS cannot run the script.
The way it is in Windows is you can register file extensions with
certain applications so when you double click on them, they run. In this case, it is configured like that. As you said, it is winblows.
Then you may need to make use of 'auto_execok' to launch the tcl
script.
saito <[email protected]> wrote:
On 3/6/2026 1:23 PM, Rich wrote:
Because winblows is not a Linux/Unix system. exec passes whatever you
give it off to the OS, and if the OS does not know how to "run" a tcl
script (and winblows does not unless you have configured it to know
how) then the OS cannot run the script.
The way it is in Windows is you can register file extensions with
certain applications so when you double click on them, they run. In this
case, it is configured like that. As you said, it is winblows.
Then you may need to make use of 'auto_execok' to launch the tcl
script.
On 3/6/2026 2:40 PM, Rich wrote:
Then you may need to make use of 'auto_execok' to launch the tcl
script.
I will have to try that! I stumbled into a solution earlier which is
the same as that suggested by meshparts.
I wonder if you have an insight into this though:
I have a socket in a script. I would like to pass it to a separate
script I am exec'ing which will write to it and then close it when it is done.
I am using this syntax:
exec $script $arg1 $arg2 >@ $sock
This command sets up the script so that the socket is now its stdout.
This works OK for files: If I open a file, and use the file handle
instead of a socket in the above statement, everything works fine. The script's output ends up in the file.
But for sockets, it doesn't work for some reason. It seems that the
script is not able to write to the socket.
Perhaps this is not possible, I am not sure.
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,099 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492373:54:21 |
| Calls: | 14,106 |
| Calls today: | 2 |
| Files: | 187,124 |
| D/L today: |
1,511 files (693M bytes) |
| Messages: | 2,496,031 |