problem with Net::SSH::W32Perl;

M

Mike Solomon

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
 
M

Mike Solomon

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");
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top