Guys you are really quick. I changed the grep statement as written by "hazylife". Added saving to file. About the answers from "kennethk" und "zentara" i need to expand my horizon the next days. For testing it now with looping up to 20 times, i just added a sleep() (temporarely). The script will run after normal working hours of the server at night. So itīs not needed to be as quick as possible.

#!/usr/bin/perl -w use Net::OpenSSH; use File::Copy; use Cwd; use strict; use warnings; #connection: my $ssh2convey99 = Net::OpenSSH->new('...'); $ssh2convey99->error and die "Couldn't establish SSH connection: ". $ssh2convey99->error; #get some data from remote host and fill array my @ls = $ssh2convey99->capture(q/disptest | fgrep ' 900 ' | fgrep - +v +1900 | grep -vE '0 ([RW]E|WAV?)' | 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 and store in the matrix foreach my $el (@ls){ $mitzl ++; @split_array = split(/;/,$el); $matrix_array[$mitzl] = [@split_array]; } #including variables, arrays, date and file for getting the needed dat +a for all list elements my @bt_matrix_array; my $length_matrix_array = @matrix_array; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localti +me(time); my $datum = sprintf "%04d%02d%02d" , $year+=1900 , $mon+=1 , $mday + ; my $file = "$datum.csv"; #running thru the list and send command to remote host for every +element. #capture everey command return in new array for(my $i = 2;$i <= 10;$i++) { my @bt = $ssh2convey99->capture("bt $matrix_array[$i][0]"); #kick out the first two lines because i donīt want them splice(@bt, 0, 2) ; #write the actual array in a file. make the file if not existi +ng. if already existing -> put the new data below the old one. add so +me meta infos open (DATEI, ">>$file") or die $!; print DATEI "TE: $matrix_array[$i][0] Boxtype: $matrix_a +rray[$i][1] \n @bt \n\n"; #make a break sleep(1); close (DATEI); } undef $ssh2convey99; my $dir = cwd; my $newdir = '//mnt/SharedFolder/'; move("$dir/$file", "$newdir/$file") or die "konnte Verzeichnis nicht o +effnen: $!\n"; ##http://perlmonks.org/index.pl?node=1080097

In reply to Re: sending hundreds of commandos on SSH connection by JGmonk
in thread 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.