From: Ken I. <fn...@ua...> - 2007-05-17 19:10:18
|
On Thu, May 17, 2007 at 11:53:52AM -0700, Jason Gerdes wrote: > Hello, > > Here is the problem I am having: > > I use expect to spawn an SSH session to a cisco router and run the > command 'show arp', which sends a lot of data back. example: > > gw>show arp > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c525.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > ... (there are thousands of lines sent back) > > The problem I get is that expect seems to process this data in chunks. > For example, it will process: > > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c5 > > where it will pull out the data correctly for the first line, but will > not match the second line since it is incomplete. Then, it processes > the next chunk. example: > > 25.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > > where it will not pull the data correctly for the first line > (incomplete), but will pull the correct data for the second line. > > I have used the TCL expect before and it does the same thing so I know > it is not a bug. I think there is just a gap in my understanding of > how expect processes the data that is sent back from spawned processes. > > Is there a way to make expect deal with all of the data as one big > chunk, rather than processing it in pieces? I hope someone can explain > how this works. If you "expect" some string or pattern that appears only after the desired output is complete, e.g., perhaps the command prompt "gw>", everything ought to be found in the before() method. -- Ken Irving |