Thread

Posted on Wed Nov 21 23:33:25 2007 by georgeking
Can't read from Channel filehandle.
I just tried Net::SSH2 out with an example derived from the Read example. I can connect, open a channel, and successfully exec a command ( I tried a simple 'pwd'). Everything seems fine. However, when I try to read from the tied file handle, the perl script seems to block.
while (my $line = <$channel>) { # never get here }
With debug enabled, it shows a poll as the last thing that happens before it blocks. If I close the channel beforehand then it doesn't block, but then there is nothing to be read. How do I get the output of my command? Happy Thanksgiving! George
Direct Responses: 6690 | 6842 | Write a response
Posted on Fri Dec 14 11:57:33 2007 by yo35 in response to 6492
Re: Can't read from Channel filehandle.
I have a similar problem. For me it work on UNIX station, but not on routers... Authentification pass, channelling pass, commands seems to pass, but I ha no response to my commands... Have you find a solution ?
Write a response
Posted on Thu Jan 10 06:06:23 2008 by sameerbhasin in response to 6492
Re: Can't read from Channel filehandle.
Hey Sameer Here I have develop this and i got the output. Check this out, i hope it will get you output. #!/usr/perl/bin -w use Net::SSH2;
my $ssh2 = Net::SSH2->new();
$ssh2->connect('station111') or die "Unable to Connect ";
if ($ssh2->auth_password('root','access')) {
my $chan = $ssh2->channel();
$returnval=$chan->exec('pwd') or die "Message\n";
my ($len,$buff);
while($len = $chan->read($buff,1024,$strErr)){
print $buff; } }else{ print "Username and Password are wrong please check $!\n"; } ~ ~
Write a response