Re: Missing lines from puts in xterm/shell window (Stdout is not in blocking mode)
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Missing lines from puts in xterm/shell window (Stdout is not in blocking mode)

From: Ivan Young <idy@jet.uk>
Date: Mon Feb 27 2006 - 15:02:07 CET

Ivan Young wrote:
> We seem to be losing output when using expect in the following way(s).
>
> Platform: Sparc / OS Solaris 7 and 10
> tcl_platform(byteOrder) = bigEndian
> tcl_platform(machine) = sun4u
> tcl_platform(os) = SunOS
> tcl_platform(osVersion) = 5.7
> tcl_platform(platform) = unix
> tcl_platform(user) = idy
> tcl_platform(wordSize) = 4
>
> Tcl 8.4.11 and 8.4.12 ActiveTcl distro.
> Expect package 5.43.0 in ActiveTcl distro. Also Expect binary built from
> source
> same version.
>
> ------------------ Test code.
> -----------------------------------------------
> #!/bin/env tclsh
> # replace tclsh above with expect or uncomment following line to use
> expect.
> # package require Expect
>
> proc testputs {} {
> set limit 10000
> set i 0
>
> while { $i < $limit } {
> puts "line number - $i"
> incr i
> }
> }
>
> testputs
>
> ------------------ end of test code
>

A little more investigation showed inserting a "fconfigure stdout -block 1 " after starting expect
or the package require, would stop lines being lost when sent to a xterm or emacs shell buffer. Even
though according [fconfigure stdout -block ] stdout was already in blocking mode.
I seem to remember postings sometime ago about the default blocking mode of expect, but that was
in context of an interactive shell session. Anyway "fconfigure stdout -block 1" does the job.

Ivan.....
Received on Sun Apr 30 02:16:49 2006