in reply to Help...Issue with Net::SSH::Perl Module

Net::SSH::W32Perl won't work with ssh1. Try this:
#!/usr/bin/perl use strict; use warnings; use Net::SSH::W32Perl; my $host = 'localhost'; my $user = 'user'; my $pass = 'password'; my $cmd = 'ls'; my $ssh = new Net::SSH::W32Perl($host, debug => 1); $ssh->login($user, $pass); my ($out, $err, $exit) = $ssh->cmd($cmd); print $out;

Replies are listed 'Best First'.
Re^2: Help...Issue with Net::SSH::Perl Module
by toddyce (Initiate) on Nov 26, 2010 at 04:10 UTC
    hi, thanks for you reply. i have tried your method, it doesn't work
    no matter Net::SSH::W32Perl or Net::SSH::Perl, if i specify
    the protocol to ssh2, then i won't work, it always hangs there.
    i find that, this module works fine on Linux, but it always has some issues on Windows.
      i find that, this module works fine on Linux, but it always has some issues on Windows.
      Do you mean the system running your perl program, or the target of the program? Is the target Linux?

      Do you have another ssh2 client program (like putty) that you can use to make sure your windows system has all the necessary libraries? It seems like the code can login, it's just when it tries to execute the command, something goes wrong.

      fnord

        thanks for your reply. yes, i ran the same script on Linux, it works fine, it can connect to the remote host and execute all the commands i sent. but on Windows, it can't. The target host is a Linux machine.
        I have SSH, putty and SecureCRT on my Windows, they all work fine.
        yes, it can login, but when executing the comand, it hangs. very strange, if i change the command as this: $ssh->cmd("ls -al > /dev/null","\n"), then it works. but i can not do that, i want the output of the command.