Just a heads up if anyone ever runs into this same issue. The problem ended up being in the Expect.pm module or more correct the IO::Tty module. The perl expect script I was running was talking to psh on the distant end and perl expect was sending a terminal window size of (0, 0) which libedit (which is used by psh) had a problem with. To solve this problem IO::Tty.pm has a function called clone_winsize_from() that allows you to set the terminal size yourself on the slave end. This ended up doing the trick:

$terminal->slave->clone_winsize_from(\*STDIN);
Adding this to any perl expect script that is having these same issues should do the trick. I have contacted the author of the Expect module and requested that he add explicit setting of the terminal window size in the "new" construct of the module. We shall see if this is in the next release.

Actually what I suggested he add to his module was the following code:

unless (eval{$self->clone_winsize_from(\*STDIN);}) { my $winsize = pack('SSSS', 25, 80, 0, 0); # rows, cols, #pixelsX, + #pixelsY ioctl($self->slave(), &IO::Tty::Constant::TIOCSWINSZ, $winsize); }
Since STDIN may not always be a tty and thus will fail a POSIX tty check in Tty.pm, I added a check for that and then explicitly set the terminal size using ioctl() manually if Tty.pm fails to do so.

This should cover both possibilities, but the portion that still allows Tty.pm to try and set it could be removed all together and just have Expect.pm explicitly set it itself every time. The above code (either method) can be added to your particular expect script too untill Expect.pm has this code. Just be sure to have the proper OO path for the function call (ie. $term->slave->clone_winsize_from(\*STDIN);).


In reply to Re: Expect.pm early termination? by Elijah
in thread Expect.pm early termination? by Elijah

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.