in reply to Re^13: SSH2 for windows
in thread SSH2 for windows

Yes - that works for me on linux, too. I changed $ssh2->connect('$hostname') ... to something valid. And I cd'd to /home/rob/pscrpt/net-ssh2 instead of shanthi_backup. That gave me the following output:
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

Unfortunately, on Win32, doing while <$chan2> simply does not work. At least I can't get it to work - the script exits and produces no output. There's quite probably someone here who knows how to fix that - unfortunately, I don't.

Only way I could find of duplicating the result on Win32 was to code it this way:
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";
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.

Sorry, that's about the best I can offer at the moment.

Cheers,
Rob

Replies are listed 'Best First'.
Re^15: SSH2 for windows
by shanthiann (Acolyte) on Mar 05, 2007 at 14:45 UTC
    Hi Robs,
    How is your health now?.
    Net::SSH2 0.10,will it work for my requirements.