From: Noah <ad...@en...> - 2007-11-15 01:34:52
|
Hi there, okay i am trying to figure out how to incorporate Matt's and Ken's advice and fit it in with the current way I've been interacting with the tot here is what I am doing. I am trying to collect all the output after sending the command 'show interfaces $interface' and stop the collection whent eh prompt has been reached. There is no need to check for 'more' or screen scrolling as I've turned that option off. A good portion of the script is shown below. The output of the command is even further below. Cheers, Noah #--- START SSH LOGIN SEQUENCE ! ----------------------------------------------# # my $command = Expect->spawn("$cmd"); $command->log_stdout(0); $command->expect($timeout, -re => "Password:") or die("Failed to get password prompt"); print $command "$password\r"; my $prompt = "$user\@[^>]+>"; $exp->expect($timeout, [ qr/$prompt/ => sub { $_[0]->send("set cli screen-length 0\n"); } ]); $exp->expect($timeout, [ qr/$prompt/ => sub { $_[0]->send("show interfaces $interface\n"); } ]); $command->expect(1, [ qr/$prompt/ => sub { my $exp = shift; exp_continue; } ] ); $exp->expect($timeout, [ qr/$prompt/ => sub { $exp->send("exit\n"); } ]); exit 0; ----- output from the command ----- 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: 4081 (00:00:04 ago) DTE statistics: Enquiries sent : 3409 Full enquiries sent : 672 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 05:19 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: 11:14:59 sec, Last down: 11:14:59 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 |