Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect matches actual command instead of output

Status
Not open for further replies.

bryan3k

Technical User
Oct 6, 2010
4
0
0
US
I have an issue where expect is matching the actual remote command instead of the output. The code is:

send "show card 1 | match down\r"
expect {
"down" {write_card_fail $host}
}

The problem is expect matches the "down" from the command and not the actual output of the command. Anyway to prevent this?

Thanks.

 
What is the output?

_________________
Bob Rashkin
 
That's the thing, sometimes there was no output but the expect command would match because the word "down" was in the command. I did find what I needed though by using the parenthesis to match newline and put things in the expect_out array. For example (this is just off the top of my head for now):

expect {
-re "(/n)(.*down)" {set x1 expect_out(2,string)}
}

This way expect doesn't start looking for a match on "down" until the newline is seen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top