I doing telnet via an Expect script, and send some command and expect the the below.
expect -re {02 : (.*?)\s}
set output $expect_out(1,string)
puts "output is $output"
=> output is 3 (this is the right answer)
set tests "02 : "
expect -re {"$tests"(.*?)\s}
set output $expect_out(1,string)
puts "output is $output"
=> output is 2 (some other value, this value is the older value present in $expect_out(1,string) that was used to search other text)
Can I save the text to be searched in a variable and pass to expect-re {....} ?
I want the text to be searched in a variable, and then pass that variable in expect..
I tried this, but it didn't work.
expect -re {($tests)(.*?)\s}