| |||||||||||
| |||||||||||
Buffering of inputs to expect, and match order
If you're using the expect command to wait for one of a series of inputs within your expect program, information will be checked in the program's internal buffers inthe following order:
a) Any string that matches expect_before will be found b) Matches to each of the possible patterns in expect in turn c) Matches to expect_after. Note that you can't be certain how much information will have been written to the internal buffer up to any point, so you need to exercise care when specifying the possible sequences. Once expect_before expect_after or expect matches as string, the section up to that string is transferred to the expect_out(buffer) variable that you can reference in your continuing Tcl, and that section is removed from the internal bugger. The following expect command will start looking from where the previous successful match was found. Note that the -notransfer option to expect will prevent the matched section from being removed from the internal buffer. The expect_background command allows you to specifiy an expect command that runs, in effect, in an asyncronous background loop. You can use it to receive inputs from processes that may be responding from time to time while you're doing other processing in the foreground, without having to go into a wait loop until one of those background processes responds. (written 2007-10-27 07:07:06) Associated topics are indexed under T242 - Tcl/Tk - More on ExpectT211 - Tcl/Tk - What is Expect? Why use it?
Some other Articles
Better technology makes for longer commutes?What we teach - expained for the non-technical The little gestures that can really count Sparse and Greedy matching - Tcl 8.4 Buffering of inputs to expect, and match order Tcl / regsub - changing a string and using interesting bits What is Expect? Wireless hotel tips - FTP and Skype connections failing Reading from another process in Tcl (pipes and sockets) Away or home - which do I prefer? 1770 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||