Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-SSH2 CPAN distribution.

Report information
The Basics
Id:
128547
Status:
rejected
Priority:
Low/Low
Queue:

People
Owner:
salva [...] cpan.org
Requestors:
nck.974 [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
0.59_20
Fixed in:
(no value)



Subject: Channel remains open after finishing command
Tested with the following code. Once you enter the filehandle there is an infinite loop there. This was working in version 58, does not work anymore since version 59. The command returns a cat of some lines in a server. my $g_ssh = Net::SSH2->new(trace => -1); $g_ssh->connect($server) or $g_ssh->die_with_error; $g_ssh->auth(username => $username, password => $password, passphrase => undef) or $g_ssh->die_with_error; my $channel = $g_ssh->channel() or do { die " [LOG ERROR]: Failed to create channel. Exiting ...\n"}; $channel->exec($command); sleep(3); while (my $line = <$channel>) { $stdout .= $line; print $line if ($debug_prints eq 1); } $channel->close(); $g_ssh->disconnect();
I've tried your example slightly modified with git master (https://github.com/rkitover/Net-SSH2) and it works correctly. There may be issues with your environment/libraries. This is the code I used: #!/usr/bin/perl use v5.28; use strict; use warnings; use Net::SSH2; my $server = 'doobie'; my $username = 'rkitover'; my $command = 'ls -l'; my $debug_prints = 1; my $g_ssh = Net::SSH2->new(trace => -1); $g_ssh->connect($server) or $g_ssh->die_with_error; $g_ssh->auth_publickey( $username, '/c/Users/rkitover/.ssh/id_rsa.pub', '/c/Users/rkitover/.ssh/id_rsa' ) or $g_ssh->die_with_error; my $channel = $g_ssh->channel() or do { die " [LOG ERROR]: Failed to create channel. Exiting ...\n"}; $channel->exec($command); sleep(3); my $stdout; while (my $line = <$channel>) { $stdout .= $line; print $line if ($debug_prints eq 1); } $channel->close(); $g_ssh->disconnect();
Subject: Re: [rt.cpan.org #128547] Channel remains open after finishing command
Date: Wed, 20 Feb 2019 12:22:50 +0000 (UTC)
To: "nck.974@gmail.com via RT" <bug-Net-SSH2@rt.cpan.org>
From: Salvador Fandino <sfandino@yahoo.com>
There was a backward incompatible change in 0.59 for READLINE (the method which gets called by <$channel>)

0.59_12  2016-04-26
        *** WARNING: backward incompatible change: "READLINE" had an
          undocumented hard coded timeout of 250ms which made the
          method unreliable. That timeout has been removed. If
          desired, the old behaviour can be attained setting
          non-blocking mode or with a global timeout.

The former READLINE implementation, made easy to write programs that worked right most of the time at the expense of making imposible to write programs that always behave correctly.




On Monday, February 18, 2019, 3:39:13 PM GMT+1, nck.974@gmail.com via RT <bug-Net-SSH2@rt.cpan.org> wrote:


Mon Feb 18 09:39:02 2019: Request 128547 was acted upon.
Transaction: Ticket created by nck.974@gmail.com
      Queue: Net-SSH2
    Subject: Channel remains open after finishing command
  Broken in: 0.59_20
    Severity: (no value)
      Owner: SALVA
  Requestors: nck.974@gmail.com
      Status: new


Tested with the following code. Once you enter the filehandle there is an infinite loop there.

This was working in version 58, does not work anymore since version 59. The command returns a cat of some lines in a server.

my $g_ssh = Net::SSH2->new(trace => -1);
    $g_ssh->connect($server) or $g_ssh->die_with_error;
    $g_ssh->auth(username => $username,
            password => $password,
            passphrase => undef) or $g_ssh->die_with_error;

my $channel = $g_ssh->channel() or do { die " [LOG ERROR]: Failed to create channel. Exiting ...\n"};
    $channel->exec($command);
    sleep(3);
    while (my $line = <$channel>) {
        $stdout .= $line;
        print $line if ($debug_prints eq 1);
    }
    $channel->close();
    $g_ssh->disconnect();


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.