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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
expect_out(buffer) Size

Posted by mansoorx (mansoorx), 29 August 2006
Hello,

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