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.
expects doesnt catch all output, large response

Posted by erickio (erickio), 29 January 2005
My topic name isn't as clear as it should be but I'm not sure how else to explain it. My program uses tcl and expect. I telnet into a router using a script, and then enter the show arp command to get the arp table. my problem occurs when i use regexp to compare to the output. it doesnt catch everything, only about 40 lines, when I know by observing that theere should be around 150-200, at least. I know this because when I sent the command, output that looks like

Internet             -   000c.86a1.6900  ARPA   Port-channel4

floods the screen for at least a minute.

When i try to print out what I caught, it only shows up with about 40 lines. However I know my script works, because when I test it on routers that have less info in their output tables, it works correctly. My questions are 1) why is this happening? and 2) is there a way to fix it?

heres some code. i dont know how helpful this is since this is a general question.


send -i $sid "show arp\n"
expect {
      -i $sid "\n" {append output $expect_out(buffer)
      -i $sid "#" {}

foreach line [split $output "\n"] {
#puts "line is $line\n"

set line [string trim $line]

if [regexp {[a-zA-Z]+[\ ]+([0-9\.\/]+)[\ ]+[0-9 a-zA-Z\-]+[\ ]+([0-9 a-zA-Z\.]+)[\ ]+[a-zA-Z]+[\ ]+([0-9 a-zA-Z\-\/]+)[\ ]*} $line gall ip mac interface] {
set marker c
#check the incomplete
if [regexp {[a-zA-Z 0-9\.\ \-]*Incomplete[a-zA-Z 0-9\.\ \-]*} $line] {
set marker i

if {$marker=="i"} {
incr ti
} elseif {$marker=="c"} {
incr tc

#puts "tc is $tc ti is $ti\n"

set inside 0
foreach a [split $intlist "\n"] {
if {$interface==$a} {
incr inside

Posted by admin (Graham Ellis), 29 January 2005
Are you setting a timeout?   If there's about a minute of responses, and you've not changed the default expect timeout of 10 seconds, that could account for the problem ... it could also be an expect buffer size limit, in which case doing multiple expects to intermediate points would help; I'm not sure what / if there's a limit there.

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