That's what test2.tcl in this [L1 ] "Regular Expressions" [L2 ] column does.
Also see the fileevent page.
The sample chapter 22 from Brent Welch's book can be downloaded from his home page and ( "TK Examples", or "TK by Example" ) [L3 ] also gives an example of this.
The link on top may not clarify this at a glance. I myself was thinking about opportunities with pipes and send, and how to handle remote command execution with both methods. See Playing with Pipes, Send and DDE - RJM
Reference to text widget.
Can anyone point to an example where a text widget displays the stdout and stderr from a command, as it is produced - not waiting until the execution finishes?