0

I currently have a background process that is taking in an input, which is generated using another program.

There are a lot of guides on how to redirect output FROM a background process, but may I know if there is a way to redirect output (i.e. generator.py) TO my background process?

An idea of how it may work (but unfortunately doesn't) is:

python generator.py | fg
  • If your background process is called by `bg.sh &` then you can redirect output to it by `python generator.py | bg.sh &` – Kristian Mar 21 '22 at 10:23
  • Related, possibly dupe: https://stackoverflow.com/questions/5374255/how-to-write-data-to-existing-processs-stdin-from-external-process – Quentin Mar 21 '22 at 10:31
  • Also https://stackoverflow.com/questions/37424497/sending-data-to-stdin-of-another-process-through-linux-terminal – Quentin Mar 21 '22 at 10:32
  • And https://stackoverflow.com/questions/49403759/pipe-to-an-existing-process – Quentin Mar 21 '22 at 10:32

1 Answers1

-1

I think you are using pipe, where you should be using redirect '<' and '>'. Pipe is like cascading commands and passing the out put of first to second, second to third, etc... When using redirect like command 1 < command 2 you are feeding command x with contents of command y. Command 2 can be a file for example,...

Have a read here: https://www.guru99.com/linux-redirection.html

ZeSousa
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '22 at 12:06