http://qs321.pair.com?node_id=959817

TravisC has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I'm brand new to coding (under a month's worth) and have found this site to be one of my gotos for info. The script I'm attempting to write establishes a telnet connection to an HP Procurve switch, reboots it, accesses it's extended boot menu, clears out all but it's basic files and reboots the switch. I'm running into a snag when I issue a command to list all current files (which is ls for this switch) I'm trying to capture the output into a string or an array, but it doesn't capture anything. the command is issued while watching the switch and I can see it list all the files, but the string or array I tell it to dump to is empty. below is the code focusing on getting the info into the array. Any and all help would be greatly appreciated.

#!/usr/bin/perl $| = 1; use Net::Telnet; use strict; use CGI; use warnings; print("content-type: text/html\n\n"); my $console_server = ('TRN-13-MRV-CON-07'); my $console_mgmtA = ('2013'); my $match; my $garbage; my $output; my @array; establishing Telnet connection my $telnet = new Net::Telnet (Timeout=>10, Errmode=>'return', Port => +$console_mgmtA); $telnet->open($console_server); $telnet->put(chr(13)); sleep(1); $output=$telnet->cmd('ls'); #to see what's in the string print("$output\n"); #take the string and create an array @array = split("\n",$output); #see what's in the array print @array; exit;