I'm trying to create a bash script that can write values into a separate python shell that is constantly running, which is expecting user input, then read back the returned value into my bash script.
Backstory: I can't just call the python script from directly within the bash script as the python script is constantly running, with a fairly long initialization which I don't want to do each time I call it.
So it can be condensed into two questions;
- How can I write to python 'user input' programmatically within bash
- How can I reliably read what is returned from the python script into a bash variable (it can be printed out and returned however I like)
I am familiar with bash basics, but I am still fairly new to it. I am guessing it has something to do with reading/writing to stderr, stdout, or stdin?
Any advice given would be very useful, thanks.