CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Array output problems

 



zeeboy
New User

Nov 23, 2011, 9:08 AM

Post #1 of 3 (496 views)
Array output problems Can't Post

HI,
I've got a script that SSH into a device then executes a command on the device. The problem is if I read the output into an array it chops off the first few characters whereas if I just read it into a variable it prints out fine. Please see the code and two outputs below...the first is the one from the variable and the second is from the array. Would you be able to help me get the array to match the output of the variable.

Thanks


Code
my $outbof = $ssh->exec ("show bof \r"); 
print ("$outbof \n");



my @outbof = split /\n/, $ssh->exec ("show bof \r");
$count=1;
while ($outbof[$count] !~ /promt/)
{
print "$outbof[$count] \n";
$count++;
}




show bof
===============================================================================
BOF (Memory)
===============================================================================
primary-image
primary-config
#eth-mgmt Port Settings:
no eth-mgmt-disabled
eth-mgmt-address
eth-mgmt-route
eth-mgmt-route
eth-mgmt-route
eth-mgmt-route
eth-mgmt-autoneg
eth-mgmt-duplex
eth-mgmt-speed
#System Settings:
wait
persist
console-speed
===============================================================================




how bof
==============================================================================
OF (Memory)
==============================================================================
primary-image
primary-config
eth-mgmt Port Settings:
no eth-mgmt-disabled
eth-mgmt-address
eth-mgmt-route
eth-mgmt-route
eth-mgmt-route
eth-mgmt-route
eth-mgmt-autoneg
eth-mgmt-duplex
eth-mgmt-speed
System Settings:
wait
persist
console-speed
==============================================================================


(This post was edited by zeeboy on Nov 23, 2011, 9:21 AM)


BillKSmith
Veteran

Nov 23, 2011, 10:47 AM

Post #2 of 3 (489 views)
Re: [zeeboy] Array output problems [In reply to] Can't Post

I strongly doubt that the posted code produced the posted output! First, the script would not terminate because the data does not contain 'promt'. Also, the first line of the second set would not loose characters, It would not be printed at all! (The element $outbof[0] is not printed)
Good Luck,
Bill


zeeboy
New User

Nov 24, 2011, 12:59 AM

Post #3 of 3 (485 views)
Re: [BillKSmith] Array output problems [In reply to] Can't Post

Hi Bill,

You're right the output has been modified and the count was set to 0 previously but the problem still remains as I am not getting the first character printed on every line.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives