Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho