Hi DeepBlue,

I'm not sure I understand what is the problem exactly. I mean your explanation is coherent but when I use expect to handle a SFTP session, this line:

#$sftp->expect(5, 'sftp>') || die("Never got sftp prompt on $targetSer +ver, ".$sftp->exp_error()."\n");
Is waiting for the SFTP prompt and then I send the upload command and then I do:
#$sftp->expect(120, 'sftp>') || die("Never got sftp prompt on $targetS +erver after upload, ".$stfp->exp_error()."\n");
to capture the end for the transmission. Whatever else gets printed is ignored and my second line only intercepts the new SFTP prompt which is pretty much single(last) line match from all the output the upload session generates. The reason is say I don't understand your problem is that I didn't do anything special for this. I simply ignore everything until I find what I expect (don;t have to ignore explicitly, just look for that you know prompts you for input).

If your regular expression you use matches some of the intermediary blurb spit out before your get prompted for input again, maybe you can change your regexp. If you have access to the install script and can modify it, maybe you can mark your prompt lines with a distinctive patters that'll help you write a regexp that won't give you false intermediary positives.

I think the bottom line is you don't ignore explicitly just match what you're looking for and try to eliminate false positives.

Hope this helps (or I totally didn't understand your problem :) )


In reply to Re: Need a solution to Expect.pm 's single line regex matching limitation by RaduH
in thread Need a solution to Expect.pm 's single line regex matching limitation by deepblue

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.