Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Some Progress, but still NEED HELP!

by cmv (Chaplain)
on Sep 21, 2009 at 14:44 UTC ( [id://796548]=note: print w/replies, xml ) Need Help??


in reply to IO::Select & ssh problem

Folks-

I'm suspecting that this is a problem having to do with both the perl version, and the ssh versions (near end and far end).

The attached script seems to be working for perl5.8, when speaking between a host running "OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006", and a far end running "OpenSSH_5.2p1-lucent-1".

However, it still fails when trying to run under perl 5.6.1, when speaking between a host running "Sun_SSH_1.1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090700f", and a far end running "Sun_SSH_1.1.1".

Update: It seems as though it has to do with the ssh version on the target machine. I've verified that things are working from a Sun_SSH_1.1.1 to a OpenSSH_5.2p1 host.

When I compare the -v outputs of the working versus non-working runs, the thing that is catching my attention is the "debug1: channel 0: write failed" message. Here is a brief excerpt of what I am seeing (in readmore's):

WORKING: ... debug1: Sending command: /usr/bin/ksh -c "cat /etc/passwd" debug2: channel 0: request exec confirm 1 debug2: fd 4 setting TCP_NODELAY debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel_input_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel 0: rcvd adjust 2097152 debug2: channel_input_confirm: type 99 id 0 debug2: exec request accepted on channel 0 debug2: channel 0: rcvd eof debug2: channel 0: output open -> drain debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed ... NOT WORKING: ... debug1: Sending command: /usr/bin/ksh -c "cat /etc/passwd" debug1: channel request 0: exec debug1: fd 4 setting TCP_NODELAY debug2: callback done debug1: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel 0: rcvd adjust 131072 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: write failed debug1: channel 0: close_write debug1: channel 0: output open -> closed debug1: channel 0: rcvd eof debug1: channel 0: rcvd close debug1: channel 0: close_read debug1: channel 0: input open -> closed debug3: channel 0: will not send data after close debug1: channel 0: almost dead debug1: channel 0: gc: notify user debug1: channel 0: gc: user detached debug1: channel 0: send close debug1: channel 0: is dead debug1: channel 0: garbage collecting debug1: channel_free: channel 0: client-session, nchannels 1 debug3: channel_free: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1) debug3: channel_close_fds: channel 0: r -1 w -1 e 7 debug1: fd 1 clearing O_NONBLOCK debug1: fd 2 clearing O_NONBLOCK Connection to host closed. debug1: Transferred: stdin 0, stdout 0, stderr 30 bytes in 15.1 second +s debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 2.0 debug1: Exit status 0 ...

I also notice in the not working case, where the bytes transferred statistics only show data being transferred on stderr. I'm currently trying to figure out how I can access this information. Any pointers are appreciated.

Also, if there is an alternative way of solving this problem, please offer a suggestion. I may not be able to get this to work.

Thanks

-Craig

use strict; use warnings; use IO::Select; my $cmd = '"cat /etc/passwd"'; my $login = 'usr@host'; my $pkey = "$ENV{HOME}/.ssh/privateKey"; my @shell = ( '/usr/bin/ksh' => ( -c => $cmd, )); my @sshcmd = ('/usr/bin/ssh' => ( -t => (), -v => (), #-vv => (), #-vvv => (), -i => $pkey, -o => 'StrictHostKeyChecking no', $login, @shell, )); open (IFILE, '-|') || exec @sshcmd; my $select = IO::Select->new(); $select->add(\*IFILE); my @ready; while ( @ready = $select->can_read(5) ) { foreach my $fh (@ready) { my $line = <$fh>; print STDERR "line=$line"; if(eof($fh)) { $select->remove($fh); close($fh) || warn "Close problem on fh: $fh"; } } } close(IFILE); END{ print STDERR "\$!: $!\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://796548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-23 23:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found