See $subject.
I run a command as:
set cmd [open "|command"]
Eventually, I close it. As one does.
How do I get the exit status (?$ in bash or %errorlevel% in dos) from 'command'? In the samples I see, they use:
catch {close $cmd} results options
The claim is that this should contain the information from the command run in the pipe.
I do not seem to get this. I'm testing on Windows.
If I run 'command' at the prompt, I see that it exits with, say, 5 (which makes sense for the command). What I get in the results is a code of 1, and typically something like "command exited unexpectedly". I do not see it doing that when run directly.
Have I missed some critical point?
The reason I am doing it as a pipe is that it can be a very long running command, and I want the Tcl program that calls it to still be active. And I want access to whatever it prints. That part is working. It seem to properly detect when the pipe is
closed (eof $cmd).
I'm basing my code on
https://wiki.tcl-lang.org/page/Execute+in+Parallel+and+Wait
Aside from getting the exit status, the code seems to work. Except I think the "catch [close $cmd] r o" should use curly brackets. I did try that to see if there was some voodoo thing going on. It made no difference.
Can I get the exit status of the command somehow?
--
Roger
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)