After several years of being interested in the capabilities of Expect I finally have an occasion to use it (and learn how it works). I'm using Expect::Simple to write test code for a shell-script-based installer that asks the user several questions before installation happens. I've got it working okay in a test environment, but when the install script finishes its work it exits (as it should) causing the Expect::Simple object to get very confused. I can't figure out how with Expect::Simple to catch this normal exit and respond appropriately. As it stands now, when the installer exits, my Expect::Simple script dies with the error:
  Expect::Simple: couldn't find prompt after send
If I catch this die and look at the $simplexpect->expect_error() value, it looks something like this:
  3:Child PID 8093 exited with status 0
Now, I could catch the die and parse the expect_error() message to look for a type 3 error with /status 0$/ in it, but surely there is a 'Simple'r way to catch the successful conclusion of the command that is being controlled by Expect::Simple.

Does anyone know of a better way to do this?

Thanks,

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."


In reply to How to handle Expect::Simple sessions to programs that end normally. by DrWhy

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.