Overview
| Artifact ID: | 30c846a9acf01b7667d401ab5c15aca6bfdd0acb |
|---|---|
| Ticket: | 30c5d37cfa0028c9ef83fa9efc490f4bc28b64ff
Expect eof occurring before end of output from spawned process |
| User & Date: | tld on 2013-08-03 08:49:22 |
Changes
- comment changed to:
I've never logged a ticket here. Apologies if I get something wrong. We initially noticed this behavior in expect scripts that were getting data from commands run on remote systems via ssh, but I've been able to duplicate the behavior in very simple expect scripts that simply spawn a process that uses cat to output a file. The behavior is somewhat unpredictable but my tests reproduce it much more often then not. What happens is that within an expect block, only in cases where the expect block does pattern matching of any kind, an eof can occur before all the data is output by the spawned command, thus truncating the output. I cannot reproduce this on an older CentOS 5 system running tcl-8.4.13 (and expect-5.43.0-8). I can however reproduce it on any system I've tried using tcl 8.5, including CentOS 6 (tcl-8.5.7-6.el6.x86_64, expect-5.44.1.15-4.el6.x86_64) and on an x86 Gentoo system (dev-lang/tcl-8.5.13-r1 and dev-tcltk/expect-5.44.1.15). As mentioned above, this only occurs if the expect block has patterns in addition to the eof. I've pasted a test script below that spawns "cat ./in.txt". I've been testing with that using: expect test.expect > out.txt ...and then... diff -w in.txt out.txt ...which will show that the output was truncated. I can reproduce this on files as small as 1000 lines and around 40-50k, with no text that would match any of the patters, and it appears that it's more likely to occur if match_max is reduced. Here is the test script. Note that some the original patterns have been left in, but don't actually need to match any text: set timeout 30 proc exitspawnstat args { catch wait result set rtn [lindex $result 2] if { !$rtn } { set rtn [lindex $result 3] } exit $rtn } log_user 1 spawn -noecho cat ./in.txt expect { eof { exitspawnstat } timeout { log_user 1 send_user "Timeout.\n" exit 253 } -nocase -re "password:" { exp_continue } "(yes/no)? " { exp_continue } -nocase -re "Enter passphrase" { exp_continue } "testing-sudo-passwd:" { exp_continue } } - login: "tld"
- mimetype: "text/plain"