Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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). –  ThorX89 Oct 31 '12 at 22:14

1 Answer 1

You might want to have a look at expect

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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