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.
expect_out(buffer) Size

Posted by mansoorx (mansoorx), 29 August 2006

       I am using expect to retrive information from the Cisco Devices, e.g,

"show interface descrition" display the list of all interfaces of the Cisco Devices,
Problem is that if the Devices interface is 24 Ports expect_out(buffer) store the result, but when port of the switch is 48 Ports expect_out(buffer) do not store the result of Cisco Commnads,

So how can i increase the Size of Expect out Buffer.

Thank You.

Posted by admin (Graham Ellis), 29 August 2006
Are you sure you have a buffer size problem rather than a timeout problem?  The buffer is dynamic and I wouldn't anticipate that size would be an issue, but the timeout might if the router / network takes a while.

Posted by mansoorx (mansoorx), 30 August 2006
Thank You for a reply,
                                  I think there is no timeout issue, i have observe, anyhow what will be the solutiuon of this problem ?  because i do it manully and its very panic

Posted by admin (Graham Ellis), 30 August 2006
The default time out is 10 seconds, and you can change it with:
set timeout 75
to change it to 75 seconds (or any other number of seconds you wish, of course.

How do you know that you don't have a time out issue? Have you already added a timeout option to your expect command and found that it wasn't activated?

Posted by mansoorx (mansoorx), 31 August 2006
I am using this Script to reterive Description of Switch Ports, i have checked by timeout but donot work, default timeout is already more than enough (10 Second) there is any other issue, because is i store description of almost 36 Port it store the Decription, but when i increase the Switch descrition upto 48 or even 40 it doesnot store, it mean its a buffer size problem not timeout.  

#!/usr/bin/expect -f
#log_user 0
spawn telnet IP
expect "Username:"
send "mansoor\r"
expect "Password:"
send "password\r"

expect [lindex $argv 1]
send "show int des\r"
#set timeout 15
expect [lindex $argv 1]
set swdes [open swdes.txt a+];
set tempvarl2 $expect_out(buffer);
#set IP = $argv 0;
puts $swdes $tempvarl2;
#puts $argv 0;

thank you.

Posted by admin (Graham Ellis), 31 August 2006
At the next step then, I would be tempted to add a loop of expects to expect each port back one by one and handle them that way.

Posted by mansoorx (mansoorx), 8 September 2006
     By using Loop i cannot get a desire information,
because when i send a "sh int des | include Fa0/3" not only port 3 inforamtion out but information of all 30 to 39 port is also collected because the infrmation of the 30 to 39 port is also match with the desired information,
 2nd thing where should i put the set timeout in our script,

Thank You.

Posted by admin (Graham Ellis), 8 September 2006
Use Tcl commands like "if" to filter out the return strings you don't want

Use expect -i to expect from multiple sources.

Would you like an example, or is that enough to go on?

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