Hi monks,

I did a little script to run ssh towards network equipment.
Works well - but now we discovered that sometimes (like 1 out of 5 runs) for a "show running config" some lines are missing...
"show running confog" gives some thousands lines and somewhere in the middle every now and than there is a block of lines missing...

Any idea????

realy every hint is welcome - this is IT and shall be deterministic :->

thanks a lot!!

===== Summary of my perl5 (revision 5 version 10 subversion 0) configuration +: Platform: osname=linux, osvers=2.4.21-297-default, archname=i686-linux-threa +d-multi uname='linux gila 2.4.21-297-default #1 sat jul 23 07:47:39 utc 20 +05 i686 i686 i386 gnulinux ' config_args='-ders -Dcc=gcc -Dusethreads -Duseithreads -Ud_sigsetj +mp -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Accflags=-DUSE_SITE +CUSTOMIZE -Duselargefiles -Accflags=-DPRIVLIB_LAST_IN_INC -Dprefix=/N +NM/perl -Dprivlib=/NNM/perl/lib -Darchlib=/NNM/perl/lib -Dsiteprefix= +/NNM/perl/site -Dsitelib=/NNM/perl/site/lib -Dsitearch=/NNM/perl/site +/lib -Dsed=/bin/sed -Duseshrplib -Dcf_by=ActiveState -Dcf_email=suppo +rt@ActiveState.com' ===== package Net::OpenSSH; our $VERSION = '0.60'; =====
use strict; use warnings; use Data::Dumper; use Net::OpenSSH; use Sys::SigAction qw( set_sig_handler sig_alarm timeout_call); use File::Path 'rmtree'; #$Net::OpenSSH::debug = -1; my $sshuser="user"; my $sshpwd="pwd"; my $sshtimeout = 90; # sec for timeout my $workertimeout = 120; my @rawout=(); my $device = $ARGV[0]; my $remoteCmd = $ARGV[1]; my $error; my $ssh; my $path = "./Y.ssh.$$"; my @sshcmds= split(';', $remoteCmd); foreach my $sshcmd (@sshcmds) { rmtree([ $path ]); $ssh = Net::OpenSSH->new( $device, user => $sshuser, passwd => $sshpwd, ctl_dir => $path, master_opts => [-o => "StrictHostKeyChecking=no", -o => "UserK +nownHostsFile=/dev/null"], timeout => $sshtimeout, kill_ssh_on_timeout => 1, strict_mode => 0, master_stderr_discard => 1 # to get rid of login screen ); if ($ssh->error) { $error = $ssh->error; chomp($error); print STDOUT "ERROR-1: " . $error . "\n"; rmtree([ $path ]); exit 1; }; if (timeout_call($workertimeout, sub{ my @cmdout = $ssh->capture({timeout => $sshtimeout, stdin_data + => "\n"}, $sshcmd."\n"); if ($ssh->error) { $error = $ssh->error; chomp($error); print STDOUT "ERROR-2: " . $error . "\n"; rmtree([ $path ]); exit 2; }; push @rawout, @cmdout; } )) { # time out action print STDOUT "ERROR-3: SSH cancled by thread after $workertime +out secs\n"; rmtree([ $path ]); exit 3; }; if ($ssh->error) { $error = $ssh->error; chomp($error); print STDOUT "ERROR-4: SSH: " . $error ."\n"; rmtree([ $path ]); exit 4; }; $ssh->master_exited; } rmtree([ $path ]); foreach (@rawout) { print STDOUT $_; } exit 0;

In reply to Net::OpenSSH loosing lines ins reply by Andy16

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.