I was wondering if I could redirect a file to the stdin of a program so that I could actually see the lines of the file as they're being used.

Suppose I have a CLI program with the following flow (in a loop): A) Computer asks question B) User answers it C) Computer responds

Running this interactively yields output (which can be copied and pasted from the terminal) that intermixes user answers with computer generated text.

I need to get the same result for a situation where the program is run non-interactively and where the answers are predefined in a file.

Running program

Is there a way to get the same kind of text that would appear on the terminal screen of such a program run interactively?

  • An equivalent question might be to ask if I can run such a program, detect if it happens to be waiting on input, and feed it a line from my file if it does (while printing the same line to the same output my program writes to).
    – PSkocik
    Oct 31 '12 at 22:14

You might want to have a look at expect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.