I have a Perl script which connects to a server using SSH2. I can run a number of commands and then the connection seems to hang, although pressing return on the client will make it continue from where it left off. Are there any options that can be set in the ssh connection to stop this from happening?

I am using Perl version 5.8.6, IO version 1.2, IO::Select version 1.13, Net::SSH::Perl version 1.25.

I changed the IO::Select and the SSH2 modules to try to debug the script. This is the output from the debug up until it hangs.
perlmgr: channel 7: new [client-session] perlmgr: Requesting channel_open for channel 7. perlmgr: Entering interactive session. After definition 1 perlmgr: Info - packet type: 91 perlmgr: Sending command: /usr/lbin/getprpw -m nullpw daemon perlmgr: Requesting service exec on channel 7. perlmgr: channel 7: open confirm rwindow 10000 rmax 16384 After definition 1 perlmgr: Info - packet type: 94 After definition 1 After definition 0 After definition 0 After definition 0
Note. This is the section I changed in SSH2.PM->client_loop to print the packet_type
while (my $packet = Net::SSH::Perl::Packet->read_poll($ssh)) { if (my $code = $h->{ $packet->type }) { $ssh->debug("Info - packet type: " . $packet->type); $code->($cmgr, $packet); } else { $ssh->debug("Warning: ignore packet type " . $packet-> +type); } } last if $ssh->_quit_pending;
Note. This is the section I changed in IO::Select->select to show where it seems to lose it's way
my $rb = defined $r ? $r->[VEC_BITS] : undef; my $wb = defined $w ? $w->[VEC_BITS] : undef; my $eb = defined $e ? $e->[VEC_BITS] : undef; print "After definition ".select($rb,$wb,$eb,$t)."\n"; if(select($rb,$wb,$eb,$t) > 0)
These are the last packets received, perlmgr being the server that the script is running on and unixmgr being the server that is being connected to

perlmgr -> unixmgr TCP D=22 S=43952 Ack=3107781192 Seq=12055 +90486 Len=0 Win=33304 Options=<nop,nop,tstamp 580143287 397338517> perlmgr -> unixmgr TCP D=22 S=43952 Ack=3107781192 Seq=12055 +90486 Len=88 Win=33304 Options=<nop,nop,tstamp 580143288 397338517> unixmgr -> perlmgr TCP D=43952 S=22 Ack=1205590574 Seq=31077 +81192 Len=0 Win=32768 Options=<nop,nop,tstamp 397338535 580143288> unixmgr -> perlmgr TCP D=43952 S=22 Ack=1205590574 Seq=31077 +81192 Len=48 Win=32768 Options=<nop,nop,tstamp 397338581 580143288> perlmgr -> unixmgr TCP D=22 S=43952 Ack=3107781240 Seq=12055 +90574 Len=0 Win=33304 Options=<nop,nop,tstamp 580143351 397338581>

20041214 Edit by ysth: code tags in readmore


In reply to ssh connection hangs by creal

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.