I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2011-11-20 22:09:40.425383-08 by waynegriswold
Last line not displayed on IOS-XR devices.
I am having trouble with Net::Appliance::Session on an IOS-XR router.
The login works fine. But the last line of the output result is always skipped.

The following example shows the command 'show cdp' which (should) return 4 result lines.
The command is shown issued at line 77 and seen at line 84.
The results (all 4 lines) are seen at lines 88-91 and 94.
The output results (missing last line) are print/displayed at lines 114-116.

The apparent problem is seen at line 94.
Why is the prompt appended to the final output line?
This appears to be why it is skipped from the final result.

It is always the same result on the XR devices.
No matter what command I run or what custom prompts or options I try...

Thank you in advance for any help or direction.


001 Session log: 002 Created temporary file /tmp/t232504.t389 003 Executing command: perl /tmp/t232504.t389 004 [0.002486] p finding prompt 005 [0.008740] t creating Net::Telnet wrapper for ssh 006 [0.009000] t command expands to: ssh -o StrictHostKeyChecking=no -l user 10.1.1.1 007 [0.315042] d SEEN: 008 009 <corporate banner removed> 010 011 [0.334777] p reading phrasebook /usr/lib/perl5/site_perl/5.8.8/Net/CLI/Interact/phrasebook +/cisco/pb 012 [0.335547] p storing prompt prompt 013 [0.336915] p storing prompt basic 014 [0.337762] p storing prompt privileged 015 [0.338551] p storing prompt configure 016 [0.339338] p storing prompt user 017 [0.340105] p storing prompt pass 018 [0.340867] p storing prompt key 019 [0.341635] p storing macro begin_privileged 020 [0.342743] p storing macro end_privileged 021 [0.343794] p storing macro begin_configure 022 [0.344841] p storing macro end_configure 023 [0.345880] p storing macro disconnect 024 [0.346918] p storing macro key_confirm 025 [0.348227] p reading phrasebook /usr/lib/perl5/site_perl/5.8.8/Net/CLI/Interact/phrasebook +/cisco/ios/pb 026 [0.348805] p storing macro paging 027 [0.349825] p nope, doesn't (yet) match basic 028 [0.350084] p nope, doesn't (yet) match pass 029 [0.350291] p nope, doesn't (yet) match user 030 [0.350497] p nope, doesn't (yet) match configure 031 [0.350697] p nope, doesn't (yet) match privileged 032 [0.350897] p nope, doesn't (yet) match key 033 [0.351330] p nope, doesn't (yet) match prompt 034 [0.351507] p no match so far, more data? 035 [0.351831] d SEEN: 036 037 <corporate banner removed> 038 039 040 user@10.1.1.1's password: 041 [0.352080] p nope, doesn't (yet) match basic 042 [0.352285] p hit, matches prompt pass 043 [0.353449] p prompt has been set to (?-xism:[Pp]assword: ?$) 044 [0.354629] e running command password 045 [0.354932] e to match (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ?$) 046 [0.355482] e executing actions 047 [0.356080] e dispatching to execute method 048 [0.357389] t callback received for send 049 [0.357670] t queueing data for send: "password" 050 [0.358003] t callback received for match 051 [0.358318] d SEEN: 052
053 [1.019180] d SEEN: 054 055 Last switch-over Mon Sep 26 13:57:59 2011: 7 weeks, 6 days, 10 hours, 29 minutes ago 056 057 RP/0/RSP1/CPU0:routerxr# 058 [1.019591] t output matched (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ?$), st +oring and returning
059 [1.020229] p setting new prompt to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ? +$)
060 [1.020509] p prompt has been set to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] +?$)
061 [1.021703] e running macro paging 062 [1.022013] e macro params are: 0 063 [1.023115] e executing actions 064 [1.023892] e dispatching to execute method 065 [1.025255] t callback received for send 066 [1.025587] t queueing data for send: "terminal length 0" 067 [1.025966] t callback received for match 068 [1.063161] d SEEN: 069 terminal length 0 070
071 [1.063491] t nope, doesn't (yet) match (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[ +#>] ?$) 072 [1.341938] d SEEN: 073 terminal length 0RP/0/RSP1/CPU0:routerxr# 074 [1.342266] t output matched (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ?$), st +oring and returning 075 [1.342964] p setting new prompt to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ? +$) 076 [1.343246] p prompt has been set to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] +?$) 077 [1.344100] e running command show cdp 078 [1.344842] e executing actions 079 [1.345634] e dispatching to execute method 080 [1.346981] t callback received for send 081 [1.347306] t queueing data for send: "show cdp" 082 [1.347687] t callback received for match 083 [1.385702] d SEEN: 084 show cdp 085 086 [1.386021] t nope, doesn't (yet) match (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[ +#>] ?$) 087 [1.640180] d SEEN: 088 show cdpGlobal CDP information: 089 Sending CDP packets every 60 seconds 090 Sending a holdtime value of 180 seconds 091 Sending CDPv2 advertisements is enabled 092 [1.640792] t nope, doesn't (yet) match (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[ +#>] ?$) 093 [1.675059] d SEEN: 094 Sending CDPv2 advertisements is enabledRP/0/RSP1/CPU0:routerxr# 095 [1.675758] t output matched (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ?$), st +oring and returning 096 [1.677148] p setting new prompt to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ? +$) 097 [1.677735] p prompt has been set to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] +?$) 098 [1.679347] e running macro paging 099 [1.679963] e macro params are: 24 100 [1.682054] e executing actions 101 [1.683567] e dispatching to execute method 102 [1.686185] t callback received for send 103 [1.686820] t queueing data for send: "terminal length 24" 104 [1.687569] t callback received for match 105 [1.718856] d SEEN: 106 terminal length 24 107 108 [1.719540] t nope, doesn't (yet) match (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[ +#>] ?$) 109 [1.954878] d SEEN: 110 terminal length 24RP/0/RSP1/CPU0:routerxr# 111 [1.955514] t output matched (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ?$), st +oring and returning 112 [1.956775] p setting new prompt to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] ? +$) 113 [1.957343] p prompt has been set to (?-xism:[\/a-zA-Z0-9._-]+ ?(?:\(config[^)]*\))? ?[#>] +?$) 114 Global CDP information: 115 Sending CDP packets every 60 seconds 116 Sending a holdtime value of 180 seconds 117 Deleted temporary file /tmp/t232504.t389 118 --- Script --- 119 001 #use warnings; 120 002 #use strict; 121 003 use Net::Appliance::Session; 122 004 123 005 my($ios_device_ip,$user,$pass) = ('10.1.1.1','****','****'); 124 006 $user =~ s/\\//g; 125 007 $pass =~ s/\\//g; 126 008 127 009 my $con = Net::Appliance::Session->new( 128 010 personality => 'ios', 129 011 host => $ios_device_ip, 130 012 transport => 'SSH', 131 013 connect_options => {shkc => 0}, 132 014 ) || die "Unable to Open Session :: $!\n"; 133 015 134 016 $con->set_global_log_at('debug');
135 017 $con->connect({ username => $user, password => $pass }) || die "Unable to Connect :: $!\n"; +
136 018 my @cdp = $con->cmd('show cdp') || die "Failed to Execute Command :: $!\n"; 137 019 138 020 print @cdp,"\n"; 139 021 140 022 $con->close; 141 --- End of Script---
Direct Responses: Write a response