| |||||||||||
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.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |