Re: [tkined] problem with exec

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Wed, 10 Jun 1998 18:13:04 +0200

>>>>> Peres Damiano writes:

Peres> Hi, I have a problem with command exec. My C application write
Peres> continuously a message on standard output, but if I use the
Peres> command [catch {exec ............ the result appear only when
Peres> the C application finish. I'd like to see a C output
Peres> continuously in Scotty too. How can I do this ?

You are asking a whole bunch of questions here. Some answers:

1) stdout is usually a buffered IO stream. A program which writes to
stdout needs to flush() the IO stream if it is not writing to a
tty device. Otherwise, output will only appear before the buffer
has filled up.
2) The Tcl exec command is blocking and returns after the process
has terminated. This is the point where you get access to the
output generated by the process. If you want to read the output
while the process is running, use a Tcl pipe (see the description
of the Tcl open command). If you want to read asynchronously, read
the documentation of the fileevent Tcl command.
3) Some programs will not work as you expect, even if you know about
1) and 2) and you have done everything right. These programs
usually insist of having a tty to write to. Use the expect Tcl
extension in these cases.

Anyway, this question is really about Tcl basics and not related to
the scotty package. The comp.lang.tcl newsgroup is probably a better
place to ask questions like this.
Juergen

Juergen Schoenwaelder schoenw@ibr.cs.tu-bs.de http://www.cs.tu-bs.de/~schoenw
Technical University Braunschweig, Dept. Operating Systems & Computer Networks
Bueltenweg 74/75, 38106 Braunschweig, Germany. (Tel. +49 531 / 391 3283)

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.