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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading standard out from a foreign executable on the fly

Status
Not open for further replies.

ImpactCorey

Programmer
May 14, 2002
4
IL
Hi,

I am trying to write a front-end in Tcl/Tk for some ancient Fortran executables. These executables may take up to a few minutes to execute but print out incremental statements to standard out. I want to be able to capture that output in my GUI and print it on the fly (as it is written) in a textbox so the user doesn't think that their machine locked up. Is there anyway that I can do this? I read somewhere to use the "open" command with a pipeline to the executable and then monitor the output using "fileevent" but I couldn't seem to get that to work. My operating system is Windows 2000.

Thanks,
Corey
 
Yes, you should be able to do this. The Tcl'ers Wiki ( has some examples of using open and fileevent to create and monitor an asynchronous process. You might want to start with "Managing Fortran programs," "fileevent," and "Tcl event loop,"
Be aware, though, that sometimes buffering issues will screw things up. (Often a program will wait to fill up an output buffer -- usually 4K in size -- before sending the results through the pipe.) Expect solves this problem quite handily, but Expect really isn't supported on Windows. If you want to read more about Expect, you can start with "Expect," - 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