in reply to Printing Output From Net::SSH2 exec
#!/usr/bin/perl use warnings; use strict; use Net::SSH2; use Data::Dumper; # assuming a user named 'z' for demonstration # connecting to localhost, so you need your sshd running # see maillist archives at # http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users # for deeper discussions 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"; #shell use my $chan = $ssh2->channel(); $chan->blocking(0); $chan->shell(); print $chan "ls -la\n"; print "LINE : $_" while <$chan>; print $chan "who\n"; print "LINE : $_" while <$chan>; print $chan "date\n"; print "LINE : $_" while <$chan>; $chan->close; __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing Output From Net::SSH2 exec
by salva (Canon) on May 14, 2009 at 12:58 UTC | |
by vortura (Initiate) on May 14, 2009 at 19:05 UTC | |
by PiLIT888 (Initiate) on Aug 20, 2009 at 19:44 UTC |