There is a some small Tk application (let's call it "launcher") which has been made for starting another script (let's call it "rocket" :-) ). I mean I run this launcher, choose/set some parameters and press button "run". Then it creates some config file which is a kind of an input for rocket. Then it should run rocket... And here I've got a problem. I need to see the process of rocket running - if I start it manually from console I see a lot of logs. I tried to run it using exec:

if [catch {exec rocket} errMsg] {
    puts "Exception: $errMsg"
    exit
}

But it seems rocket starts logging into it's own output or whatever - I can't see anything in the console. And I haven't found any way to redirect it somewhere else except files.

Who knows, how to drive the output flow of child process? Or maybe there is another way to resolve the initial task?


AMG: You will need to capture its stdout and stderr and write to a text widget. Here's the simplest way:

set command {ls /}            ;# Unix example
set command {cmd /c dir C:\\} ;# Windows example

package require Tk
text .t -yscrollcommand {.s set} -state disabled
scrollbar .s -orient vertical -command {.t yview}
pack .s -side right -fill y
pack .t -side left -fill both -expand 1
proc receive {chan} {
    .t configure -state normal
    .t insert end [read $chan]
    .t configure -state disabled
    .t see end
    if {[eof $chan]} {
        close $chan
    }
}
set chan [open |[concat $command 2>@1]]
fconfigure $chan -blocking 0
fileevent $chan readable [list receive $chan]

Things get tricky if you want to handle stdout and stderr separately, for instance give them different colors. See [L1 ] for more information.