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

capturing input from stdin

Status
Not open for further replies.

piedycat

Technical User
May 31, 2002
7
0
0
GB
Win98 tcl 8.3.4
I have a script which will launch a console exe file and capture the output into a text widget using the procedures below. This is fine if the application needs no input from the user via keyboard, but how do i get the application to wait for input if required, and get it? I do not want to have to pipe input in from a text file which contains all the input needed.
Any suggestions which don't require Expect as I'm not using NT please if possible.
Thanks in advance
Mark





proc Run {} {
global command input log but
if [catch {open "|$command"} input] {
$log insert end $input\n
} else {
fileevent $input readable Log
$log insert end $command\n
$but config -text Stop -command Stop
}
}

# Read and log output from the program

proc Log {} {
global input log
if [eof $input] {
Stop
} else {
gets $input line
$log insert end $line\n
$log see end
}
}
 
The only way I can see to manage the keyboard input of a Windows console app is to 'Tclize' it:
gluing the app in a wish script that will do the input thru widgets.

Hope that help

ulis
 
There is a page in the Tcler's Wiki that seems of interest for you at Titled "Managing Fortran programs" this page from Arjen Markus "is meant to elaborate the management of interactive Fortran programs via Tcl". It contains a sketchy Tcl program which "asks for a string and puts it to an executable program".

Maybe that can help you.

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top