1
votes

I want to use expect_out to get the output for the last send for the following snippet

while {[gets $cmds command]>=0} {
    send "$command\r"
    expect "*"
    set result $expect_out(buffer)
    puts $gout $result
}

but expect_out(buffer) seems to maintain all previous outputs how can I achieve my goal? thanks

1
I don't think it's guaranteed how much $expect_out(buffer) will hold at all, other than that it is enough to match what the expect that produced it required to match. - Donal Fellows

1 Answers

2
votes

Untested, but try adding another expect * before sending the command.

When in doubt while developing an expect program, add exp_internal 1 to the top of your script.