in reply to Re^3: Printing Output From Net::SSH2 exec
in thread Printing Output From Net::SSH2 exec

Net::SSH2 is working for me. Commands that take a while to return back to shell are fine now:

my $ssh2 = Net::SSH2->new();
$ssh2->connect("$host") or die $!;
my $chan = $ssh2->channel();
$chan->blocking(1);
$chan->exec("rpm -qa |wc|awk '{print \$1}'");
$chan->read($buf, $len);
my @output;
while (<$chan>) { push(@output,$_); }
my $stdout=join ("", @output);
print $stdout;
  • Comment on Re^4: Printing Output From Net::SSH2 exec