Posted on 2009-03-20 20:11:22-07 by quandarypeak
OUTPUT NOT ASSIGNED TO ARRAY
Using SSH to run a command on a Cisco router the module isn't assigning the output of the cmd to an array. Look at the code and results below. The array size is zero !!! The STDOUT proves that the command is running but the array is zero. HELP !!!
&ios_login($ip,$username,$password,$ssh); @lines = $session_obj->cmd('ping 1.1.1.1'); $size = scalar @lines; print "@lines size= $size\n"; foreach $line (@lines) { print "$line\n"; if ($line =~ /Success rate is (\d+)/) { $rate = $1; print "Rate=$rate\n"; } } $session_obj->close; ------- OUTPUT ------- size= 0 ping 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/8/12 ms
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.