perldragon80 has asked for the wisdom of the Perl Monks concerning the following question:
I am setting up a Mason environment with Apache(2.0.53) and mod_perl2, and am trying to use the Net::SSH::Perl(1.27) module behind the scenes to get some info from another linux machine. I can login and execute the command, but before it finishes the $session->cmd process hangs. I setup a shell example(below) with the same syntax (and all modules except Mason env and it works fine). I setup a CGI::Application env, which uses the same module and it works fine.....
Even if I send a bogus command in the Mason env example, the shell gives an error back and cmd exits, but for any legit command I don't get back any output and it hangs(sits there till I kill the server). I have tried something as simple as ls, or in this case ps.
my $sshSession = Net::SSH::Perl->new($address, debug => 'true', protoc +ol => '2,1'); # Login works fine $sshSession->login('xxxxxx','xxxxx') || die "Ssh login Didn't wo +rk"; my $command = "ps aux"; # Execute a command my ($out, $err, $exit) = $sshSession->cmd($command); # hangs while executing ...
The debug from each side (ssh-perl and sshd) can be seen here:
Here is the end debug from the sshd side:howboutdat: Login completed, opening dummy shell channel. howboutdat: channel 0: new [client-session] howboutdat: Requesting channel_open for channel 0. howboutdat: channel 0: open confirm rwindow 0 rmax 32768 howboutdat: Got channel open confirmation, requesting shell. howboutdat: Requesting service shell on channel 0. howboutdat: channel 1: new [client-session] howboutdat: Requesting channel_open for channel 1. howboutdat: Entering interactive session. howboutdat: Sending command: ps aux howboutdat: Requesting service exec on channel 1. howboutdat: channel 1: open confirm rwindow 0 rmax 32768 howboutdat: input_channel_request: rtype exit-status reply 0 howboutdat: channel 1: rcvd eof howboutdat: channel 1: output open -> drain howboutdat: channel 1: rcvd close howboutdat: channel 1: input open -> closed howboutdat: channel 1: close_read # Hangs right here
debug1: input_session_request debug1: channel 1: new [server-session] debug1: session_new: session 1 debug1: session_open: channel 1 debug1: session_open: session 1: link with channel 1 debug1: server_input_channel_open: confirm session debug1: server_input_channel_req: channel 1 request exec reply 0 debug1: session_by_channel: session 1 channel 1 debug1: session_input_channel_req: session 1 req exec debug1: PAM establishing creds debug1: fd 11 setting O_NONBLOCK debug2: fd 11 is O_NONBLOCK debug1: fd 14 setting O_NONBLOCK debug2: channel 1: read 344 from efd 14 debug2: channel 1: rwin 32768 elen 344 euse 1 debug2: channel 1: sent ext data 344 debug1: Received SIGCHLD. debug1: session_by_pid: pid 24263 debug1: session_exit_message: session 1 channel 1 pid 24263 debug1: channel request 1: exit-status debug1: session_exit_message: release channel 1 debug1: channel 1: write failed debug1: channel 1: close_write debug1: channel 1: output open -> closed debug1: session_close: session 1 pid 24263 debug1: channel 1: read<=0 rfd 11 len 0 debug1: channel 1: read failed debug1: channel 1: close_read debug1: channel 1: input open -> drain debug2: channel 1: read 0 from efd 14 debug2: channel 1: closing read-efd 14 debug1: channel 1: ibuf empty debug1: channel 1: send eof debug1: channel 1: input drain -> closed debug1: channel 1: send close debug2: notify_done: reading debug3: channel 1: will not send data after close ### Hangs right here ########
I have been able to narrow the issue down, but not solve it entirely. I can use SSH1 (with use_pty => 1) and it works fine in the Mason environment. When I try to use SSH2, it gets all the way to the channel close read portion, but hangs in the call to $select_class->select(IO::Select module). It isn't the original call either but the last call to select in the client loop(SSH2.pm) before exit. For whatever reason the last call to $select_class->select($rb,$wb) gets all the way to the end of the select function but won't return the @result. For now I guess I'll use SSH1, but would like to figure out the solution so I can pass it on to anyone else who experiences this problem.
|
|---|