merge stdin, stdout?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Feb 4 21:20:22 EST 2010


On 01:56 am, jonny.lowe.12345 at gmail.com wrote:
>Hi everyone,
>
>Is there an easy way to merge stdin and stdout? For instance suppose I
>have script that prompts for a number and prints the number. If you
>execute this with redirection from a file say input.txt with 42 in the
>file, then executing
>
>./myscript < input.txt > output.txt
>
>the output.txt might look like this:
>
>Enter a number:
>You entered 42.
>
>What I want is to have an easy way to merge input.txt and the stdout
>so that output.txt look like:
>
>Enter a number: 42
>You entered 42.
>
>Here, the first 42 is of course from input.txt.

It sounds like you might be looking for script(1)?

Jean-Paul



More information about the Python-list mailing list