Hi All,
I am connecting to a remote host and excute commandos on the remote shell. First it gives me back a list of data what i am splitting up in arrays. Now i want to send a new commando for every item in the array and store the result.

I am not sure about what to use for more than 1000 commandos. below is the code how i prepared it now. I trierd the loop with size of 5 items - > this works. But i am worried about run it with 1000 items and how the remote server reacts.

#!/usr/bin/perl -w use Net::OpenSSH; use strict; use warnings; #connection: my $ssh2convey99 = Net::OpenSSH->new('...'); $ssh2convey99->error and die "Couldn't establish SSH connection: ". $ssh2convey99->error; #get some date from remote host and fill array my @ls = $ssh2convey99->capture("disptest | grep -E ' 900 ' | grep -v +1900 | grep -E -v '0 RE' | grep -E -v '0 WE' | grep -E -v '0 WAV' | g +rep -E -v '0 WA' | awk '{print \$3\";\", \$6\";\" }'"); $ssh2convey99->error and die "remote ls command failed: " . $ssh2convey99->error; # include variables and arrays for data preparation my @split_array; my @matrix_array; my $mitzl = 0; # prepare the data an store in the matrix foreach my $el (@ls){ $mitzl ++; @split_array = split(/;/,$el); $matrix_array[$mitzl] = [@split_array]; } #including variables and arrays for getting the needed data for all li +st elements my @bt; my @bt_matrix_array; my $length_matrix_array = @matrix_array; #running thru the list and send commando to remote host for every ele +ment. #store all input in new matrix for(my $i = 2;$i <= $length_matrix_array;$i++) { @bt = $ssh2convey99->capture("bt $matrix_array[$i][0]"); $bt_matrix_array[$i-1]=[@bt]; }

this will be the output for 1 element of the loop and the loop will send more than 1000

Welcome to lemans1 (LINUX) Order: 967065/1 Box 282477 Zeit | Stat | Info | Soll + | Ist ----------------+---------+-----------------------------------+------ +-+------- 20140328090153 | AV2 | TLJ3,gerade | + | 20140328090155 | ER01A | TS01,gerade | + | 20140328090204 | LJ7 | TS01,gerade | + | 20140328090213 | S01 | TK1,gerade | + | 20140328090305 | K1 | TS03,gerade | + | 20140328090353 | S03 | TS04,gerade | + | 20140328090415 | S04 | TS06,gerade | 0 + | 230 20140328090438 | S06 | TS08,gerade | + | 20140328090459 | S08 | TS11,gerade | + | 20140328090522 | S11 | TS12,gerade | 0 + | 220 20140328090624 | S12 | TS14,gerade | + | 20140328090645 | S14 | TS16,gerade | + | 20140328090707 | S16 | TS19,gerade | + | 20140328090730 | S19 | TS19,gerade | + | 20140328090911 | S19 | TK3,gerade | 284 + | 310 20140328090954 | K3 | TK5,gerade | + | 20140328091001 | K5 | TK1,gerade | + | 20140328091023 | K1 | TK2,gerade | + | 20140328091033 | K2 | TS28,gerade | + | 20140328091129 | S28 | TS28,gerade | 0 + | 320 20140328091514 | S28 | TS30,gerade | 414 + | 410 20140328091537 | S30 | TS32,gerade | + | 20140328091557 | S32 | TS33,gerade | + | 20140328093457 | S32 | TS35,gerade | + | 20140328093520 | S35 | TER05,weight | 618 + | 550 20140328095704 | S35 | TS20,gerade | 0 + | 580 20140328095806 | S20 | TS22,gerade | + | 20140328095830 | S22 | TS24,gerade | + | 20140328095849 | S24 | TS27,gerade | + | 20140328095912 | S27 | TS27,gerade | + | 20140328100053 | S27 | TK3,gerade | 703 + | 680 20140328100100 | K3 | TWG07,gerade | + | 20140328100201 | WG07 | TSK1,gerade | 0 + | 680 20140328100208 | SK1 | TSK1,gerade | + | 20140328105059 | ESM1 | TERR,lost | + | 20140328110542 | ESM1 | TERR,gerade | + |

what comes after is to write the data in a file during it loops.

thanks for your advice how to do it correctly.


In reply to sending hundreds of commandos on SSH connection by JGmonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.