Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching vi from inside tcl?

Status
Not open for further replies.

WaltS

Programmer
Mar 11, 2002
13
US
Is there a way to launch vi on a file from within tcl? Using eval and/or exec only seems to hang my program.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top