Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: How can I connect to a Linux Machine from a Windows Box

by blackadder (Hermit)
on Apr 05, 2007 at 12:48 UTC ( [id://608469] : note . print w/replies, xml ) Need Help??


in reply to Re^3: How can I connect to a Linux Machine from a Windows Box
in thread How can I connect to a Linux Machine from a Windows Box

Hi

"....Are you sure you have the correct protocol? Are you actually usin +g SSH? "
Erm, all I know is that I use a Putty session to connect (via port 22, I've just checked it). I enter user= root and the password and hey presto I am in. I want to do just this is in a script!

Anyway this is what I've tried
use Net::SSH qw(sshopen2); use strict; my $user = "root"; my $host = "149.195.49.155"; my $cmd = "ls -l"; sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; while (<READER>) { chomp(); print "$_\n"; } close(READER); close(WRITER);
And this is what I got!!:
C:\Scripts>esx_conn3.pl 'ssh' is not recognized as an internal or external command, operable program or batch file.
An example code would be great.

Does this help? Cheers.

Blackadder

Replies are listed 'Best First'.
Re^5: How can I connect to a Linux Machine from a Windows Box
by marto (Cardinal) on Apr 05, 2007 at 12:58 UTC
    By default SSH runs on port 22, so yes you need to connect using the SSH protocol. Regards example code, did you read the documentation? There are examples there. The error message you are getting is because you have:

    use Net::SSH qw(sshopen2);

    when you want something like:

    use Net::SSH qw(ssh issh sshopen2 sshopen3);.

    Again, read the documentation for a further information and example code.


    Update: Crapola, please ignore the part of this post which has been struck out. Thanks to ikegami for pointing out my mistake.

    Hope this helps

    Martin
      He's not using ssh, issh or sshopen3, so he doesn't need to import those. It looks like the library is trying to use the external utility ssh, but cannot locate it. Is that one of the module's dependacies?
        Gadzooks, I was too hastey. From the documentation:

        For an all-perl implementation that does not require the system ssh command, see Net::SSH::Perl instead.

        Martin