| |||||||||||
Reading out from expect_out Posted by skumar003 (skumar003), 23 January 2003 Please see the following function.I am reading from the expect_out buffer, compare with "check " if it matches return Success else return FAIL. The above procedure which is meant to do just that when called always fails for the first time and succeeds for the 2nd time, fails 3rd time , succeeds 4th time.Every alternate time it Fails and succeeds even though every time check = port_response_buffer Can anyone figure out why? ---------------------------- proc portcheck { check } { global port_response_buffer global current_tc_rc global swit_debug if { [regexp $check $port_response_buffer] } { write_log "***Success***\n" return } else { write_log "***Failed***\n" set current_tc_rc 1; if {$swit_debug} { send_user "\nU R now in interactivemode:\n" send_user "Type CTRL-a to continue\n" send_user "Type OFF to get off interactive mode\n" send_user " Type control-c to exit\n" interact { \001 { return } "debugoff" { set swit_debug 0} \003 { exit } } } return } } ------------------------------ [/b][i][/i][b][b][/b] Posted by admin (Graham Ellis), 24 January 2003 Hi, Welcome ....I've had a quick look at the code snippet in your post and can't spot anything wrong ... I would be very interested to look at your calls to the expect command in your main code. Can you also post some examples of the values that you have in $check and $port_response_buffer please. Two guesses, or rather things to check ... a) regexp looks for a match to a regular expression in a string. If the regular expression includes control characters, you don't necessarily get a match even if the two variables have identical content. For example, if they both contained ab+c, then you would get a failure as you're trying to match the string ab+c to a pattern describes as "contains an a, one or more b's and a c" - note no reference to the "+" b) In some circumstances, it's hard to know how much expect will match - especially the case where you put something "wild" such as .* on the end of it and the process that you've spawned is trickling data through to you. Is it possible that this is happening? Posted by skumar003 (skumar003), 28 January 2003 Graham,The point U mentioned in item B was happenning. I had step into the code and spend a lot of time to fix it. Thanks for the hint. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |