Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a tool that can receive some parameters via system(...) but also needs (and waits for) some STDIN input that is needed. The program has no option to read this out of a file or to input via a parameter. Does there exist any way to automate this STDIN so the program does not wait for it or if it has to wait, to make that STDIN coming from a file or whatever? I hape I didnt confuse you. Thank you very much.

Replies are listed 'Best First'.
Re: How to input STDIN
by friedo (Prior) on Dec 14, 2005 at 18:08 UTC

      Expect is overkill for this. Expect need only be used when there is interactice input AND output (you need to send something, wait for something, send something else...) or when the application is actually insisting that the input come from a tty. If the application will accept input on STDIN and all you want to do is feed it, you just need a pipe instead of system:

      open(EXTERNAL, "|your-command-goes-here with-its-arguments") or die; print EXTERNAL "The external program will receive this on STDIN\n"; close EXTERNAL;

      Some external commands ignore STDIN and go straight to the controlling tty to get their input because they want to guarantee that it comes from a user, not another program. passwd is typically one of them. That's when you need Expect.

        Tank you very... much
      Thank you but as I see Expect does not support ActivePerl. Does there exist any other method?