Yes, it is possible, at least under Unix. (I just tested this successfully on a machine running Mandrake Linux 8.1.) By default,
exec intercepts the standard IO channels of the program it starts, which is quite handy if you want to capture the output of a program you run. But
exec also lets you redirect the standard IO channels as desired. And by using a special syntax described in the
exec documentation, you can redirect individual IO channels on the program you run to channels already open in your Tcl script. Check the
exec documentation for more details, but the following line starts
vi and hooks up its IO channels to your terminal:
Code:
exec vi <@ stdin >@ stdout 2>@ stderr
Notice that this example waits until
vi is finished executing before continuing with your script. You also can append an ampersand (&) as the last argument to the
exec command to run
vi and return immediately. But this is a bit dangerous, as
vi was started as a child of your Tcl script, and if your Tcl script terminates while
vi is still running, your
vi session gets killed. So I personally wouldn't do that. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax