Hello Monks!

At Expect-1.21 (debian unstable version) and at Expect-1.32 (Gábor Szabó version), I can read:
My script fails from time to time ... try using $exp->soft_close()
And later:
This will wait 15 seconds for a process
I have search at the code, and the delay is on Expect.pm:
$end_time = time() + 15;
   while ( $end_time > time() ) {
Well, my question is.. I have configured ssh ControlMaster to yes. Playing with Expect, the first connection will delay such 15 seconds:
system ('ssh -O exit localhost 2> /dev/null;'); use Expect; print Expect::version(); $su=new Expect; $su->log_user(1); $su->spawn ("ssh localhost echo aa"); $su->soft_close(); # this step hang 15 seconds # $su->expect(undef); exit 0;
If I try it with a not ssh master initial conection it works:
system ('ssh -O exit localhost 2> /dev/null; ssh -M localhost -fN 2> /dev/null'); use Expect; $su=new Expect; $su->log_user(1); $su->spawn ("ssh localhost echo aa"); $su->soft_close(); # this step now will not take more than 1 second #$su->expect(undef); exit 0;

At the first moment I thought it was a ssh issue, but it run fine without Expect Perl module

Do you know what is happen there (why perl 'system' call detect the finish of ssh commands but Expect not)?

PD: To setup this example, you need pubkey auth on localhost (ssh-keygen + ssh-copy-id + ssh-agent (search about ssh passwordless if you did not know about)) Pd2: updated to clarify the question

In reply to ssh controlmaster and expect perl module by i5513

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.