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.
Unable to capture the entire result in expect_out(

Posted by rsk (rsk), 7 October 2006

   We are using TCL/Expect to send CLI commands to NE (network element).

We see that the expect_out(buffer) does not capture the complete output of the command. This happens for commands with huge output.

When we print the buffer we see that it displays only a part of output.

The output has totally 67274 lines,
but is displays from 66136 to 67117.

We get a timed out problem because the script expects to see the prompt (which should be the last line of buffer) after the output which is missing in the buffer.

We increased the buffer size (using match_max) and also the timeout value but the problem still exists.

Request you to give some pointers.



Posted by admin (Graham Ellis), 7 October 2006
I have seen several reports like this ... and I've usually recommended that the expect_out data is captured line by line rather than all into one big buffer.

Posted by rsk (rsk), 9 October 2006
We are not able to conclude on this problem, we see that the behaviour is not consistent. Sometimes it writes the complete output of the command into the buffer and sometimes it only writes few lines. what could be the reason.

Posted by admin (Graham Ellis), 9 October 2006
Inconsistent results are often caused by timing issues.   You set off a spawned process, and then you have your expect process do a bit of housekeeping and say "can I see xxxxx in the buffer".    Depending on how the remote operation / timesharing algorithm in your own computer get on, you'll match partial or whole return patterns.   The problem is especially common in you end an expect regular expression with a catch-all such as .* or any count, or if you have a near-timeout case.

How did you get on with my suggestion of receiving the response back line by line, rather than grabbing the whole response in one go?   Expecting up to \r or \n should have done wonders for you, even though it's a bit more coding.

This page is a thread posted to the opentalk forum at 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: • WEB: • SKYPE: wellho