In general, expect
will save the expect's whole match string in expect_out(0,string)
and buffer all the matched/unmatched input to expect_out(buffer)
. Each sub match will be saved in subsequent numbering of string such as expect_out(1,string)
, expect_out(2,string)
and so on.
foreach card $cardlist {
send "./gen_info.py [string tolower $card] /usr/dump_log/Dump_Log/Apollo_log/PCB2C/$card\n"
set timeout 200
expect_before timeout {
log_puts "gen_info.py for $card timeout"
log_puts $expect_out(buffer)
abort
}
# regexp matching is using greedy mode
expect -re {/home/insieme.*json} {
log_puts "gen_info.py for $card succeeded"
log_puts $expect_out(0,string) # no space between 0 and string
set json_card($card) $expect_out(0,string)
}
}