Search code examples
linuxinputconsole.readline

linux pass text into readline of a given process


I've got a process that reads console input from user (readline, raw_input, etc. - depending on platform). There is another process that wants to feed the first process with a given input.

How to do this in linux? Is it possible? PS the language I'm interested is Python, but hints on any language/platform are appreciated.


Solution

  • The first option:

    Python provides subprocess package to perform this task. You need to use pipes provided with subprocess package. Reference here.

    The second option:

    You can use multiprocessing package for better control and more options; pipes still available. Additionally you can use Queue, Array and Lock to facilitate interprocess communication. Reference here.