Hi Gilbert,
I used expect a lot but it was a decade ago. The problem of synchronizing the input with the output is tough because of buffering. Also I expect the prof does not want the input/output just merged but the input be highlighted in some way so that the student can quickly identify it.
I was using expect to make decisions based on the output of the program which does get complicated.
I checked for expect samples and they really do not do what you want.
-- Bill
On 25/11/11 14:16, Gilbert E. Detillieux wrote:
On 2011-11-25 14:07, Bill Reid wrote:
I think the TCL expect package might do the trick. It simulates a person entering text in a terminal session. The command and output are intermix as you want.
I though about "expect", but figured that it might be a bit too low-level, and more complicated, than what I'm looking for. This has to be easy enough for novice UNIX users to use. (It's essentially to run a test suite on their programs, written in Prolog. Yikes!)
I'm also not very familiar with actually coding for "expect" (though I've tweaked other people's expect scripts, and at least know a bit about how to use it), and the prof is not at all familiar with it.
Would it be easy to write an expect script to do what I want? (I.e. feed the input from a file, line-by-line, to a program, and collect all the output, including tty echo, into a file?)
Gilbert
On 25/11/11 13:56, Gilbert E. Detillieux wrote:
Howdy folks!
I got a request from a prof this morning that stumped this old UNIX hack. He wants to run a UNIX command (for a language interpreter), using input from a file, and saving a transcript of the output. That much is trivial. The catch is that he'd like the transcript to have the input echoed, as if it had been typed in at the tty.
I've looked at options on the script command and ssh, but can't find a simple solution to this. And it has to be simple enough for his students (who may not have much UNIX experience) to use.
Any suggestions?