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

STDOUT is missing the lines in total - numbers and content.
Then, the problem is very likely to be Sig::SigAction breaking some builtin at an inconvenient time and corrupting perl internal state.

Anyway, running the program with strace may also give some hint.

Replies are listed 'Best First'.
Re^15: Net::OpenSSH loosing lines ins reply
by Andy16 (Acolyte) on Jun 04, 2014 at 16:02 UTC
    Hi,

    stripped it down to that level:
    #!perl -w use strict; use warnings; use Data::Dumper; use Net::OpenSSH; my $sshuser="user"; my $sshpwd="pwd"; my $device = $ARGV[0]; my $sshcmd = $ARGV[1]; my $error; my $ssh; my $path = "./Y.ssh"; $ssh = Net::OpenSSH->new( $device, user => $sshuser, passwd => $sshpwd, ctl_dir => $path, master_opts => [-o => "StrictHostKeyChecking=no", -o => "UserKnown +HostsFile=/dev/null"], strict_mode => 0, master_stderr_discard => 1 # to get rid of login screen ); my @cmdout; my @cmdout2; @cmdout2 = $ssh->capture({stdin_data => "\n"}, $sshcmd."\n"); open FILE, "<", "./rawout.txt"; @cmdout = <FILE>; close(FILE); $ssh->master_exited; foreach (@cmdout) { print $_; } exit 0;



    YES - program is for testing ONLY
    no sense !!

    BUT
    output misses some lines from time to time!!

    Output is FINE if I don't run the capture

    back to you - I'm out of ideas now, at least for today

    Thanks for help!!

      Don't call master_exited. Though that would probably not solve anything.

      What is print returning?

      for (@cmdout) { my $bytes = print $_; print STDERR "bytes: $bytes, err: $!\n"; }

      Also, use strace in order to see what is going on at the OS level.

        Hi Salva,

        good ideas, will follow up tomorrow,
        but hard to do - as I have to read the full output line by line every time to find, if there is one missing...
        If I only count the lines - I miss the info.

        grrr...