in reply to Re: Net::OpenSSH loosing lines ins reply
in thread Net::OpenSSH loosing lines ins reply

Hi Salva,

thanks for picking that up!

I changed the code:
if (timeout_call($workertimeout, sub{ $ssh->system({ timeout => $sshtimeout, stdin_data => "\n", stdout_file => "/tmp/ssh_del_$$.txt" }, $sshcmd."\n"); open FILE, "<", "/tmp/ssh_del_$$.txt"; my @cmdout = <FILE>; close(FILE); # my @cmdout = $ssh->capture({timeout => $sshtimeout, stdin_da +ta => "\n"}, $sshcmd."\n"); # if ($ssh->error) # { # $error = $ssh->error; # chomp($error); # print STDOUT "ERROR-2: " . $error . "\n"; # rmtree([ $path ]); # exit 2; # }; push @rawout, @cmdout; }


and tested again.

Funny:
I just count the number of lines in the output - and it still differs!
BUT: the files in /tmp are all the same size!!!

strange, or?

Replies are listed 'Best First'.
Re^3: Net::OpenSSH loosing lines ins reply
by salva (Canon) on Jun 04, 2014 at 11:10 UTC
    That probably means that there are some bug on the server SSH implementation (the other possibility being a bug on the OpenSSH ssh client which is very stable and mature and unlikely to have bugs like that).
Re^3: Net::OpenSSH loosing lines ins reply
by Andy16 (Acolyte) on Jun 04, 2014 at 11:53 UTC
    ... and even more fun....

    changed the printing part of the script:

    my $tmpcnt=0; open TWO, ">", "./two.out"; foreach (@rawout) { print "$tmpcnt: ". $_; print TWO "$tmpcnt: ". $_; $tmpcnt++; }


    after running I "tee" stdout to a file and "wc -l" after "tee".
    Sometimes "wc -l" shows a reduced number.
    Then, the tee'ed file also misses a block of lines.
    BUT two.out contains all of them.

    argh!
      Which PerlIO layers are attached to the file handlers?
      use Data::Dumper; my $tmpcnt=0; open TWO, ">", "./two.out"; print STDERR Dumper [PerlIO::get_layers(\*STDOUT)]; print STDERR Dumper [PerlIO::get_layers(\*TWO)]; foreach (@rawout) { print "$tmpcnt: ". $_; print TWO "$tmpcnt: ". $_; $tmpcnt++; }
        $VAR1 = [ 'unix', 'perlio' ]; $VAR1 = [ 'unix', 'perlio' ];


        thinking the direction: is OpenSSH fiddling around with "my" STDOUT? Feels like I cannot print to STDOUT for a very short time...