in reply to Re^13: SSH2 for windows
in thread SSH2 for windows
LINE : /home/rob/pscrpt/net-ssh2 LINE : total 12 LINE : -rw-r--r-- 1 rob rob 334 Dec 9 19:51 exec.pl LINE : -rw-r--r-- 1 rob rob 453 Dec 15 11:09 shell.p +l LINE : -rw-r--r-- 1 rob rob 443 Feb 10 15:05 shell2. +pl
That produces exactly the same output as I've shown above. It's obviously not ideal - for one thing you need to allocate a sufficiently large buffer in advance. If the buffer isn't big enough, you'll lose info.use warnings; use strict; use Net::SSH2; my $buflen = 500; my $buf = '0' x $buflen; my $ssh2 = Net::SSH2->new(); $ssh2->connect('192.168.0.3') or die "Unable to connect Host $@ \n"; $ssh2->auth_password('user','password') or die "Unable to login $@ \n" +; my $chan2 = $ssh2->channel(); $chan2->blocking(1); $chan2->exec("cd /home/rob/pscrpt/net-ssh2 && pwd && ls -lrt"); $chan2->read($buf, $buflen); $chan2->close; chomp $buf; $buf =~ s/\n/\nLINE : /g; $buf = "LINE : " . $buf; print $buf, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^15: SSH2 for windows
by shanthiann (Acolyte) on Mar 05, 2007 at 14:45 UTC |