From: Bradford R. <bt...@po...> - 2007-11-14 20:59:35
|
On Nov 14, 2007 3:46 PM, Noah <ad...@en...> wrote: > > > > > I'm assuming the output is coming from a remote connection to something, > > not a command run at the shell... I'm pretty sure expect can do that, > > but I would need more details. Can you give some sample output and an > > example of what you consider a "match" that you want to save? You'll > > probably end up calling expect over and over again to get each match, so > > that means you may also need to look for something that tells you when > > to stop looking. > > > > > Hi, > > okay I am attempting to grab the interface and Unit number like > t1-1/1/0.0 for each logical interface to t1-1/1/0.9, the Input rate, > Output rate, and the remote IP address out of the following output: > > > > sample output - yup the results from a JUNOS CLI command. *Sounds like you really only need expect to do the remote connection/login part. If it were me, I would do the minimum with expect to just send the command and capture all of the output to an array (ie. one call to expect, using the prompt as the "match" string), and then parse the output the way you would normally parse an input stream, like with a foreach loop or something. * > > > Physical interface: t1-1/1/0, Enabled, Physical link is Down > Interface index: 141, SNMP ifIndex: 38 > Link-level type: Frame-Relay, MTU: 1504, Clocking: Internal, Speed: T1, > Loopback: None, FCS: 16, Framing: ESF > Device flags : Present Running Down > Interface flags: Hardware-Down Link-Layer-Down Point-To-Point > SNMP-Traps Internal: 0x4000 > Link flags : Keepalives DTE > ANSI LMI settings: n391dte 6, n392dte 3, n393dte 4, t391dte 10 seconds > LMI: Input: 0 (never), Output: 2310 (00:00:08 ago) > DTE statistics: > Enquiries sent : 1930 > Full enquiries sent : 380 > Enquiry responses received : 0 > Full enquiry responses received : 0 > DCE statistics: > Enquiries received : 0 > Full enquiries received : 0 > Enquiry responses sent : 0 > Full enquiry responses sent : 0 > Common statistics: > Unknown messages received : 0 > Asynchronous updates received : 0 > Out-of-sequence packets received : 0 > Keepalive responses timedout : 1 > CoS queues : 4 supported, 4 maximum usable queues > Last flapped : 2007-10-19 20:11:51 UTC (3w5d 00:27 ago) > Input rate : 0 bps (0 pps) > Output rate : 0 bps (0 pps) > DS1 alarms : LOF, LOS > DS1 defects : LOF, LOS > > Logical interface t1-1/1/0.1 (Index 72) (SNMP ifIndex 5946) > Description: globbers1 > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 10.10.10/24, Local: 10.10.10.1, Broadcast: > 10.10.10.255 > Addresses, Flags: Dest-route-down Is-Preferred > Destination: 192.168.1.0/30, Local: 192.168.1.1, Broadcast: > 192.168.1.3 > DLCI 1 > Flags: Down, DCE-Unconfigured > Total down time: 06:22:08 sec, Last down: 06:22:08 ago > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.2 (Index 73) (SNMP ifIndex 5947) > Description: globbers2 > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.4/30, Local: 192.168.1.5, Broadcast: > 192.168.1.7 > DLCI 2 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.3 (Index 74) (SNMP ifIndex 5948) > Description: globbers3 > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.8/30, Local: 192.168.1.9, Broadcast: > 192.168.1.11 > DLCI 3 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.4 (Index 75) (SNMP ifIndex 5949) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.12/30, Local: 192.168.1.13, Broadcast: > 192.168.1.15 > DLCI 4 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.5 (Index 76) (SNMP ifIndex 5950) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.16/30, Local: 192.168.1.17, Broadcast: > 192.168.1.19 > DLCI 5 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.6 (Index 77) (SNMP ifIndex 5951) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.20/30, Local: 192.168.1.21, Broadcast: > 192.168.1.23 > DLCI 6 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.7 (Index 78) (SNMP ifIndex 5952) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.24/30, Local: 192.168.1.25, Broadcast: > 192.168.1.27 > DLCI 7 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.8 (Index 79) (SNMP ifIndex 5953) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.28/30, Local: 192.168.1.29, Broadcast: > 192.168.1.31 > DLCI 8 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > > Logical interface t1-1/1/0.9 (Index 80) (SNMP ifIndex 5954) > Flags: Device-Down Point-To-Point SNMP-Traps Encapsulation: FR-NLPID > Input packets : 0 > Output packets: 0 > Protocol inet, MTU: 1500 > Flags: None > Addresses, Flags: Dest-route-down Is-Preferred Is-Primary > Destination: 192.168.1.32/30, Local: 192.168.1.33, Broadcast: > 192.168.1.35 > DLCI 9 > Flags: Active > Total down time: 0 sec, Last down: Never > Input packets : 0 > Output packets: 0 > DLCI statistics: > Active DLCI :8 Inactive DLCI :1 > > > > |