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 portion from Net::SSH::Perl..
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
Here is the end debug from the sshd side:
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 ########
If have searched other nodes and googled quite a bit, but can't seem to find anyone else who has experienced this problem. I assume it is related to the import/export expections of HTML::Mason/Apache::Request and Net::SSH::Perl, but obviously have no idea.
Update:

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.


In reply to Net::SSH::Perl hangs(during cmd), but only in Mason environment by perldragon80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.