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. | [reply] |
| [reply] |
Any particular reason why you don't want to use modules? As a general rule of thumb you'll find that using modules instead of reinventing the wheel is generally considered a good thing :-)
--
vek
-- | [reply] |