[Ssh-sftp-perl-users] Net::SSH2 don't see the result of commands
Brought to you by:
dbrobins
From: Serge L. <ser...@gm...> - 2007-02-10 17:30:46
|
HI, I'm trying to see the result of executing "uname -a" on my host. Unfortunately, there is no output from the script. Could you please point me what I do wrong? I tried to do it with opensuse 10.2 and FC 5, perl v5.8.8, *libssh2-0.14 , Net-SSH2-0.09 * Note: Everything is ok If I do the following $chan->exec('uname -a > /tmp/my'); my $sftp = $ssh2->sftp() or die $!; my $fh = $sftp->open('/tmp/my') or die $!; print $_ while <$fh>; so the lib and module are working, but I guess it's a bad way. Script: --------------------------------------8<----------------------------------------- #!/usr/bin/perl -w use strict; use Net::SSH2; my $ssh2 = Net::SSH2->new(); print "connect fail\n" unless ($ssh2->connect('127.0.0.1')); print "password fail\n" unless ($ssh2->auth_password('root', 'xxx')); # test1 my $chan=$ssh2->channel(); $chan->shell(); print $chan "uname -a\n"; print "LINE : $_" while <$chan>; $chan->close; # test2 $chan=$ssh2->channel(); $chan->exec('uname -a'); while (<$chan>){ print $_ } ; $chan->close; exit 0 --------------------------------------8<----------------------------------------- -- Sincerely Serge Leschinsky |