Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: NET::OpenSSH to execute multiple commands

by toolic (Chancellor)
on Aug 24, 2012 at 20:27 UTC ( #989638=note: print w/ replies, xml ) Need Help??


in reply to Re^2: NET::OpenSSH to execute multiple commands
in thread NET::OpenSSH to execute multiple commands

foreach $Line ( @Output || @Output2 ) {
The foreach loop will probably get executed only once, and $Line will take on a value equal to the number of elements in the @Output array. You probably want a comma, like I showed.


Comment on Re^3: NET::OpenSSH to execute multiple commands
Re^4: NET::OpenSSH to execute multiple commands
by hmb104 (Sexton) on Aug 24, 2012 at 21:55 UTC
    ($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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-08-20 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (118 votes), past polls