in reply to help on Net::SSH2

Also, if you want to return the output of the channel, the docs say it acts like a tied filehandle, so......
#!/usr/bin/perl use warnings; use strict; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect('localhost') or die "Unable to connect Host $@ \n"; $ssh2->auth_password('z','ztester') or die "Unable to login $@ \n"; #works #my $sftp = $ssh2->sftp(); #my $fh = $sftp->open('/etc/passwd') or die; #print $_ while <$fh>; # A channel object is created by the Net::SSH2 "channel" method. # As well as being an object, it is also a tied filehandle. my $chan = $ssh2->channel(); $chan->exec('ls -la'); while (<$chan>){ print }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: help on Net::SSH2
by shanthiann (Acolyte) on Aug 22, 2006 at 11:51 UTC
    Thanks
    yes it is printing the values.
    how can ,if i want to change the directory and list the files.
    more over,i have to do lot of commands in single channel
      Read "perldoc Net::SSH2::Channel". You can combine the stderr and stdout with 'merge', so you can see the remote error messages. If you want to run mutiple commands, you can use "shell" or just create as many channels as you need, like $chan, $chan1, $chan2, etc. and run exec on them in an sequential order. Another option may be to use the SFTP object, if you just want dir listings.

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum