Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/expects-doesnt-catch-all-output-large-response.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
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))
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  40.60.12.17             -   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)
                   exp_continue
                   }
      -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 www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© 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