Well, if you don't want your code to have "use Expect;" in it, then you might consider looking at Expect.pm, taking the parts from it that matter for your application, and copying them into your code.

Note that /bin/passwd is an especially tough example for this sort of thing -- to quote Abigail-II's reply to a another recent thread on a similar topic: ... passwd reads directly from the (pseudo)-terminal, not from STDIN.

update: my suggestion of copying from the module wasn't intended to be facetious -- well, not entirely -- but by starting down that path, you will get a good sense of the handicap that comes with seeking a no-modules solution for this sort of problem. I haven't looked at the Expect.pm source code -- it might very well use (depend on) other modules, and you'd need to copy relevant code from them as well.

Granted, there is the rare situation where module installation is beyond your personal control, and you need a work-around. But then again, for things that involve unix user-accounts and related security issues, we should not expect (or want) work-arounds to be an easy matter -- e.g. if it's hard or impossible to execute /bin/passwd via a CGI script (e.g. because the sysadmin won't provide Expect.pm in this context), that's not an unreasonable situation, and it would be quite foolish to circumvent that.


In reply to Re: IPC/Expect w/o modules by graff
in thread IPC/Expect w/o modules by Sapient2003

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.