problem with Net::SSH::W32Perl;

Discussion in 'Perl Misc' started by Mike Solomon, Sep 20, 2004.

  1. Mike Solomon

    Mike Solomon Guest

    I am trying to use Net::SSH::W32Perl;

    I wrote the following test script

    use strict;

    my $host = 'myhost';
    my $user = 'user';
    my $pass = 'password';
    my $cmd = 'ls';

    use Net::SSH::W32Perl;

    my ($ssh, $out, $err, $exit);

    my %args;
    $args{debug} = 1;
    $args{protocol} = 2;

    $ssh = new Net::SSH::W32Perl($host, %args);
    $ssh->login($user, $pass);

    ($out, $err, $exit) = $ssh->cmd("ls");

    print "OUT: [$out]\n";
    print "ERR: [$err]\n";
    print "EXIT: [$exit]\n";

    the screen gives the following output then hangs

    mjstecra: Reading configuration data /.ssh/config
    mjstecra: Reading configuration data /etc/ssh_config
    mjstecra: Connecting to myhost, port 22.
    mjstecra: Socket created, turning on blocking...
    mjstecra: Remote protocol version 1.99, remote software version
    OpenSSH_3.5p1 FreeBSD-20030201
    mjstecra: Net::SSH::perl Version 1.25, protocol version 2.0.
    mjstecra: No compat match: OpenSSH_3.5p1 FreeBSD-20030201.
    mjstecra: Connection established.
    mjstecra: Sent key-exchange init (KEXINIT), wait response.
    mjstecra: Algorithms, c->s: 3des-cbc hmac-sha1 none
    mjstecra: Algorithms, s->c: 3des-cbc hmac-sha1 none
    mjstecra: Entering Diffie-Hellman Group 1 key exchange.
    mjstecra: Sent DH public key, waiting for reply.
    mjstecra: Received host key, type 'ssh-dss'.
    mjstecra: Host 'newred.gradwell.net' is known and matches the host
    key.
    mjstecra: Computing shared secret key.
    mjstecra: Verifying server signature.
    mjstecra: Waiting for NEWKEYS message.
    mjstecra: Enabling incoming encryption/MAC/compression.
    mjstecra: Send NEWKEYS, enable outgoing encryption/MAC/compression.
    mjstecra: Sending request for user-authentication service.
    mjstecra: Service accepted: ssh-userauth.
    mjstecra: Trying empty user-authentication request.
    mjstecra: Authentication methods that can continue:
    publickey,password,keyboard-interactive.
    mjstecra: Next method to try is publickey.
    mjstecra: Next method to try is password.
    mjstecra: Trying password authentication.
    mjstecra: Login completed, opening dummy shell channel.
    mjstecra: channel 0: new [client-session]
    mjstecra: Requesting channel_open for channel 0.
    mjstecra: channel 0: open confirm rwindow 0 rmax 32768
    mjstecra: Got channel open confirmation, requesting shell.
    mjstecra: Requesting service shell on channel 0.
    mjstecra: channel 1: new [client-session]
    mjstecra: Requesting channel_open for channel 1.
    mjstecra: Entering interactive session.
    mjstecra: Sending command: ls
    mjstecra: Requesting service exec on channel 1.
    mjstecra: channel 1: send eof
    mjstecra: channel 1: open confirm rwindow 131070 rmax 32768
    mjstecra: input_channel_request: rtype exit-status reply 0
    mjstecra: channel 1: rcvd eof
    mjstecra: channel 1: output open -> drain
    mjstecra: channel 1: rcvd close

    Has anyone got any idea how I can make this work
     
    Mike Solomon, Sep 20, 2004
    #1
    1. Advertising

  2. Mike Solomon

    Mike Solomon Guest

    (Mike Solomon) wrote in message news:<>...
    > I am trying to use Net::SSH::W32Perl;
    >
    > I wrote the following test script
    >
    > use strict;
    >
    > my $host = 'myhost';
    > my $user = 'user';
    > my $pass = 'password';
    > my $cmd = 'ls';
    >
    > use Net::SSH::W32Perl;
    >
    > my ($ssh, $out, $err, $exit);
    >
    > my %args;
    > $args{debug} = 1;
    > $args{protocol} = 2;
    >
    > $ssh = new Net::SSH::W32Perl($host, %args);
    > $ssh->login($user, $pass);
    >
    > ($out, $err, $exit) = $ssh->cmd("ls");
    >
    > print "OUT: [$out]\n";
    > print "ERR: [$err]\n";
    > print "EXIT: [$exit]\n";
    >
    > the screen gives the following output then hangs
    >

    snip

    I solved it

    Doing a bit of research I found that the command needs a "\n" and
    mustnt put any out put to screen

    so the following works

    my $host = 'myhost';
    my $user = 'user';
    my $pass = 'password';

    use Net::SSH::W32Perl;

    my ($ssh, $out, $err, $exit);

    my %args;
    $args{debug} = 1;
    $args{protocol} = 2;

    $ssh = new Net::SSH::W32Perl($host, %args);
    $ssh->login($user, $pass);
    ($out, $err, $exit) = $ssh->cmd('ls > mike.txt',"\n");
     
    Mike Solomon, Sep 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    159
  2. prabu
    Replies:
    0
    Views:
    90
    prabu
    Mar 15, 2006
  3. Replies:
    3
    Views:
    201
  4. seth

    Net::SSH::W32Perl - hanging

    seth, Mar 17, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    153
  5. 0m
    Replies:
    1
    Views:
    326
Loading...

Share This Page