Command Piping & Expect

Command Piping & Expect

Post by Tom Wil » Fri, 10 Aug 2007 12:22:34


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
 
 
 

1. Pipe search of command procedure log file containing pipe search command.

2. Pipe a pipe command to a file

I couldn't find any better place to post this, so here it is:

I'm trying to find a way to echo a pipe command (>>) to a file.

Basically I'm trying to have one batch file create another batch file on the
fly. Unfortunately one of the commands already has a pipe command in it:

FOR /F %%I IN ('%1') DO ECHO %%~I >>%2

So to pipe it to a batch file, I would normally do this:

echo FOR /F %%I IN ('%1') DO ECHO %%~I >>%2 >> c:\test.bat

Unfortunately this fails because there are two sets of pipe commands (>>) in
the line.

Is there a way around this, maybe a way to specify ASCII characters in place
of >>?

Thanks,
--
Bill Baker

3. Pipe search of command procedure log file containing pipe search command. command.command.

4. Pipe search of command procedure log file containing pipe search command. command.command.

5. Pipe search of command procedure log file containing pipe search command. command. command.

6. Pipe search of command procedure log file containing pipe search command. command. command.

7. Help: Can VB open a command prompt and pipe commands?

8. Piping output of one command into builtin "read" command

9. pipe file input into command line command

10. expect - "puts" command not synchronized with interacting commands like "send..."

11. expect - "puts" command not synchronized with interacting commands like "send..."

12. expect - "puts" command not synchronized with interacting commands like "send..."

13. problem connecting pipes in Expect.pm

14. popen, Pipes with programs that expect user input