When I run the example code it completes the SCP and the SFTP calls with no problem whatsoever, but when trying to use a channel it fails. It appears that everything works ok, authentication, etc, but I get zero output using a channel.
<br><br>I turned on debug and and this is the output I get:<br><br>daryl@seclab10:~/CPAN/Net-SSH2-0.09/example> ./read.pl <br>[user daryl]<br>Password: [user daryl]<br>libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type, window_size, packet_size, ((void *)0) , 0 ) -> 0x8362f88
<br>Net::SSH2::poll: timeout = 250, array[1]<br>- [0] = channel<br>- [0] events 1<br>- libssh2_poll returned 0<br>- [0] revents 0<br>Net::SSH2::Channel::DESTROY<br>Net::SSH2::DESTROY object 0x8180488<br>daryl@seclab10:~/CPAN/Net-
SSH2-0.09/example> <br><br>Here is the code as I ran it for the above output:<br><br>#!/usr/bin/perl -w<br><br># Sample Net::SSH2 code illustrating several ways to read the remote<br># /etc/passwd file.<br><br>use Net::SSH2;
<br>use IO::Scalar;<br><br>my $ssh2 = Net::SSH2->new;<br>$ssh2->debug(1);<br>die "can't connect" unless $ssh2->connect('localhost');<br># use an interactive authentication method with default callback
<br># (if a password is provided here, it will forward it without prompting)<br>die "can't authenticate"<br> unless $ssh2->auth(username => scalar getpwuid($<), interact => 1);<br><br>sub _read {
<br> my $handle = shift;<br> while (my $line = <$handle>) {<br> chomp $line;<br> $line =~ s/:.*$//;<br> print "found user '$line'\n";<br> }<br>}<br><br># (c) type it over a channel
<br>$chan = $ssh2->channel;<br>$chan->exec('cat /etc/passwd') or die;<br>_read($chan);<br><br><br><br>Thank You<br><br> - Daryl<br>