Expect script stops working after upgrade to 20021217-1
Bradley Holdridge
Bradley.Holdridge@motorola.com
Thu Dec 26 13:33:00 GMT 2002
An expect script I've been using for well over a year stopped working
once I upgraded to 20021217-1. The problem still existed after I
upgraded to 20021218-1. When I backed out to version 20010117-1, the
script resumed functioning correctly.
The script dies thusly (although the strings displayed after "invalid
command name" and "while executing" vary):
-------------------------------------
expect: does "\r\n=== Received trap ===\r\n" (spawn_id 4) match regular expression "=+ +(Journaled Event [(]C[^:]*: +([0-9]+|0x[0-9A-Fa-f]+), +S[^:]*: +([0-9]+|0x[0-9A-Fa-f]+)[)]) +=+ *[\n\r]+"? no
"=+ +(Received trap) +=+ *[\n\r]+"? yes
expect: set expect_out(0,string) "=== Received trap ===\r\n"
expect: set expect_out(1,string) "Received trap"
expect: set expect_out(spawn_id) "4"
expect: set expect_out(buffer) "\r\n=== Received trap ===\r\n"
===== Received trap =====
expect: does "" (spawn_id 4) match regular expression "^toolname@4812_25> "? no
"([^\n\r]*)[\n\r][\n\r]"? no
expect: does "toolname@4812_25> \r\n=== Sending set ===\r\n" (spawn_id 4) match regular expression "^toolname@4812_25> "? yes
expect: set expect_out(0,string) "toolname@4812_25> "
expect: set expect_out(spawn_id) "4"
expect: set expect_out(buffer) "toolname@4812_25> "
invalid command name "f]"
while executing
"f]"
invoked from within
"expect_user -nobrace -re "^ *auto-journaling +(on|off) *\[\n\r]+" {
send_log $expect_out(buffer)
set auto_journaling [ expr { $expec..."
-------------------------------------
What it's attempting to do
First, it matches "===== Received trap =====" via the second regexp in this pattern:
expect_before {
-re "=+ +(Journaled Event \[(]C\[^:]*: +(${num_pat}), +S\[^:]*: +(${num_pat})\[)]) +=+ *\[\n\r]+" {
send_user "\n===== $expect_out(1,string) =====\n"
dump_output
send_special_set $expect_out(2,string) $expect_out(3,string)
}
-re "=+ +(Received trap) +=+ *\[\n\r]+" {
send_user "\n===== $expect_out(1,string) =====\n"
dump_output
}
-re "=+ +(Discarded trap from \"\[0-9.]+\") +=+ *\[\n\r]+" {
send_user "\n===== $expect_out(1,string) =====\n"
dump_output
}
-re "=+ +(Sending set) +=+ *\[\n\r]+" {
send_user "\n===== $expect_out(1,string) =====\n"
dump_output
}
}
Then, it runs dump_output to dump the output from the spawned process
until the tool prompt is encountered. The expect script dies after
matching the prompt string regexp:
proc dump_output {} {
global prompt
set old_before [ expect_before -info ]
set old_after [ expect_after -info ]
expect_before
expect_after
expect {
-re "^${prompt}" {}
-re "(\[^\n\r]*)\[\n\r]\[\n\r]" {
send_user " $expect_out(1,string)\n"
exp_continue
}
}
expect_before -brace $old_before
expect_after -brace $old_after
}
-------------------------------------
A couple times I've also seen it fail as below but never when I've had
the "exp_internal" display enabled:
===== Received trap =====
can't unset "unknown_pending(": no such variable
while executing
"unset unknown_pending($name)"
(procedure "unknown" line 35)
invoked from within
""
invoked from within
"expect_user -nobrace -re "^ *auto-journaling +(on|off) *\[\n\r]+" {
send_log $expect_out(buffer)
set auto_journaling [ expr { $expec..."
--
Bradley Holdridge
Bradley.Holdridge@motorola.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20021226/9bcaf5d0/attachment.txt>
-------------- next part --------------
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list