try catch - real-time TCL exec output -
i have following scenario:
if { [catch { exec echo calling big script } exec_msg] } { puts "nok" puts "output of big script: $exec_msg" } else { puts "ok" puts "output of big script: $exec_msg" }
are there solutions print $exec_msg in real-time, in sync execution of big script?
if do:
exec echo calling big script >@stdout # wrapped around exec same; omit brevity
then output script written straight standard out. however, lose ability read tcl script. read script, can try (on unix):
exec echo calling big script | tee /dev/tty
however tend delay output until accumulates few kilobytes @ time (a feature of how programs output non-terminals). fixing requires use of expect, lot more complicated, or maybe creating pipeline , handling asynchronously. it's substantial step in trickiness you've been doing, , it's because you're starting fight against how programs work naturally. frank, you're better off avoiding sort of thing if don't need it.
Comments
Post a Comment