find the script below: #!/usr/bin/perl -w use strict;
use Term::ReadKey; use Net::SSH2; use constant BUFLEN => 10_0000; my $user = "user"; print "Enter the the password: "; ReadMode 'noecho'; my $pass = ReadLine 0; print "\n"; chomp $pass; ReadMode 'normal'; open INPUT, "<", "input.txt"; open STDERR, ">", "Error.txt"; while(<INPUT>) { chomp $_; my $ssh2 = Net::SSH2->new(); unless ($ssh2->connect("$_")) { print "unable to connect to Host: $_\n"; print STDERR "Unable to connect to $_: $!\n"; print STDERR "#############################################################################################\n\n"; next; } print "connecting to $_\n"; unless ($ssh2->auth_password("$user","$pass")) { print "Invalid Password\n"; exit; } my $chan = $ssh2->channel; $chan->exec('sh run'); my $buf; my $read = $chan->read($buf, BUFLEN); warn 'More than ', BUFLEN, ' characters in listing' if $read >= BUFLEN; open OUTPUT, ">", "$_.txt"; print OUTPUT "HOST: $_\n\n"; print OUTPUT "$buf\n"; print OUTPUT "\n\n\n"; print OUTPUT "##################################################################################################\n\n"; close OUTPUT; $chan->close(); } Thanks On Thu, Mar 11, 2010 at 12:58 AM, Sisyphus <sisyph...@optusnet.com.au>wrote: > > ----- Original Message ----- From: "perl_haxor 123" <perl.ha...@gmail.com> > To: <beginners@perl.org> > Sent: Thursday, March 11, 2010 6:07 AM > Subject: stripped output from Net::SSH2 > > > > Hi All, >> >> I'm using Net::SSH2 module on windows machine, the purpose of this >> script is to login to multiple devices and execute "show run" command and >> print the output of the command to a text file, .......the script login >> to >> multiple devices and executes "show run" command", reads from the channel >> buffer and dumps the output to a text file.....but the problem is the text >> file doesn't contain the full output, the last few lines are stripped >> out..........Does anybody know what the problem could be? >> >> > Could you provide a small (minimal) script that demonstrates the problem ? > (Remember to remove password and any other sensitive information before > posting.) > > Cheers, > Rob >