($Core) = &connect( $Core, $user, $pass );
@Output = $Core->capture( "show ip route $IPNumber" ) or
die( ($! >> 8) );
$DEBUG && Debug_Output( @Output );
($Core2) = &connect( $Core2, $user, $pass );
@Output2 = $Core2->capture( "show run | include hostname" ) or
die( ($! >> 8) );
$DEBUG && Debug_Output( @Output2 );
foreach $Line ( @Output, @Output2) {
if ( $Line =~ m/^Routing entry for / ) {
@Data = split( ' ', $Line );
$Subnet = $Data[ 3 ] ;
}
if ( $Line2 =~ m/^hostname / ) {
@Data2 = split( ' ', $Line2 );
$Rname = $Data2[ 2 ] ;
last ;
}
}
@Subnet = split( /\./, $Subnet );
$RouterIP = join( '.', $Subnet[0], $Subnet[1], $Subnet[2], '1' );
print( " Router: [$Rname]\t Router IP: [$RouterIP]\n" );
The loop doesn't featch my Output2 array elements. This is what I get in the command line:
bash-3.00$ ./test 10.10.10.16
Router: [] Router IP: [10.10.10.1]
The router name is empty.