Marco
Marco

Reputation: 1232

TCL data capture issue - expect

I would like to know how to get the output of the previous command with TCL.

I have the following structure now:

exp_send -i $spawn_id "show port-access supplicant\r"

set buff ""
expect -regexp {".*"}
    expect -regexp ".*#" {send "show port-access supplicant\r"}
expect eof

*The command at this point returns the right info, but I don't know how to store it into a variable.

I was reading about the expect_out, but I couldn't make it work !

Upvotes: 0

Views: 354

Answers (1)

Niall Byrne
Niall Byrne

Reputation: 2460

You can use the expect buffer to do this. Complete your 2 matches:

 expect -regexp ".#" {send "show port-access supplicant\r"}
 expect -regexp ".#"; #Match the prompt again after the device output returns

And then try:

 puts $expect_out(buffer)

Upvotes: 1

Related Questions