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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: 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