Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Command Piping & Expect

23 views
Skip to first unread message

Tom Wile

unread,
Aug 8, 2007, 11:22:34 PM8/8/07
to
Using Windows XP and ActiveState 8.4 w/Expect 5.43 (or is it 5.34?)

I have two scripts.

The first is a command script keeping track of several (~15) separate
tclsh processes.

Each of those 15 processes are running a single expect script. All
processes are running at the same time.

The command script keeps track of all of these processes with command
piping. i.e.
open "| tclsh expect_script.tcl" RDWR

All the command pipes (both in the command script and individual
processes) are running w/o blocking and with line buffering. The
input/output is dealt w/by fileevents.

So, when I print to stdout in one of the expect script processes it is
read in the command script, parsed, and dealt with.

_Before_ I spawn a telnet session in the expect script all communication
is as you'd expect. Anything output to stdout in the expect script
triggers a readable event in the command script, I get a line, and parse
it correctly.

_After_ I spawn a telnet session in the expect script this does not
happen. Everything output to stdout in the expect script is not picked
up by the command script. However, if I double up the [puts] commands,
one of the [puts] commands gets through. i.e.

puts "foobar"
puts "foobar"

If I use the above, everything works as you'd expect w/a single [puts].

I have judicious wait times (using vwait/after, so I'm in the event
loop) in both command and expect scripts. I've tried blocking mode and
different types of buffering. I've tried flushing stdout. I've tried
greater wait times. I've tried it with from 1 to 15 expect scripts
running w/o any difference.

Using [set ::exp::winnt_debug 1] I can tell that as far as the command
script is concerned, only one [puts] command is being read. In other
words, if the expect script writes out X times, the command script reads
X times, not 2 * X.

So, I'm really curious what I'm actually seeing here. Has anyone
seen/heard/some resemblance of an idea of what's going on?

- Tom

0 new messages