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
Expect

Posted by skumar003 (skumar003), 3 February 2003
How do I match for strings in the expect out buffer.
I can check for one of the words that matches the buffer but not 2 or 3 words.

How can I do that.



Posted by admin (Graham Ellis), 4 February 2003
Ah ... there are two things that could both be considered to be the expect output buffer ....

Firstly, there's the string of information that expect is receiveing from the spawned process, which you match using the expect command itself.    When you run the expect command, it looks for information to match (in turn)
specified in an earlier expect_before
specified in the current expect
specified in an earlier expect_after
and it keeps trying until there's correct information in the buffer to succeed (or until a timeout).

Once you've got control back in your program from your expect command, you have an array called expect_out with all sorts of useful bits of information in it that you can refer back to.  I normally use regular expressions to do my matches to these various buffers ...

You ask about matching several words, and I notice that you've posted items talking about phone numbers / people / names etc. If you're looking for several words in the same buffer, you may be looking for something as easy as a regular expressions
    "Kumar.*Tel.*4567"
which means "Contains Kumar, then perhaps some other characters, then Tel, then perhaps some other characters, then 4567"



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., 2012: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho