Reading from the expect out buffer
Posted by skumar003 (skumar003), 10 April 2003I am matching patterns from the expect out buffer. The buffer is kind of large and I have set the match_max to 10000.
Even then I cannot match the bottom 3rd of the buffer because it is not there.
All pattern matches after about 2/3rds fail as it is not present.
1)What is the max size of the buffer that we can set to?
2)Is there any way to concat or lappend the buffer of 1 to the other to match patterns?
PLease offer your thoughts.
Posted by admin (Graham Ellis), 11 April 2003Firstly, a copy of the process output is kept in expect_out(buffer), so even if it's too big to match to, you do have a copy that you can further manipulate if you wish.
I would be surprised if the match_max variable couldn't be set to at least 32000 if you need it to be larger than the 10000 - I've had a look in Don Libes' book and the 10000 quoted there is an example. You might also like to read carefully his description of what match_max actually is - in summary, it's the maximum size that can be reliably matched and sometimes the matched string can be much longer.
Finally, if you use expect to get back a number of shorter matches rather than one huge one, there is nothing to stop you using a tcl command such as append to join the sections together into a single variable.
Posted by skumar003 (skumar003), 5 May 2003Please look at this scenario,
in a ftp session I do
Now this is in the expect out buffer and If i check the buffer using regexp to look for x.exp it will pass even if x.exp may not be there(may not be fetched using the ftp session).
How do I handle such a scenario? Please offer your thoughts.
Posted by admin (Graham Ellis), 6 May 2003You can tell expect to wait for one of any number of different sequences, so all you need to do is to establish what are the possible responses if x.exp doesn't exist, and if it does. Here's an example from one of our courses, where we're trying to log in to a system as an FTP server. If there is a web server running on the system, we get a login prompt. If there isn't, we get an error message followed by an ftp> prompt, and if the system can't be reached, it times out.
With an mget, it depends on what ftp client your using and whether or not (if it's the Linux / Unix standard client) you specify the -i option when you spawn it. You'll need to run both a sucessful and a failed mget ftp manually and make a careful note of the behaviour of the client as you choreograph your Expect.
Aside - expect takes options to allow you to wait for matches to a regular expression or a glob style sequence. If you use them, take care that the match cannot occur any earlier in the response sequence and give you a false return.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho