I'm new to Python, and I'm given an engine in bash (which takes its own unique commands from a command line prompt or a file and exercises a specific functionality). I want to subprocess it through Python.
I'm able to open the engine with subprocess.call(path, shell=True)
, and manually interact with it / input commands, but I cannot figure out how to script the unique commands to input into the engine through Python, to see the outputs automatically. I've tried to understand all of the documentation, but it is so, so verbose.
Ideally I would like to script all of my input commands in Python, subprocess the engine, and see the output from my engine in the Python output.
Again, forgive me if this sounds confusing. For example, I've tried:
p = subprocess.Popen(path-to-engine, stdin = subprocess.PIPE, stdout = subprocess.PIPE, shell=True)
p.stdin.write("some commands")
p.stdout.readline()
p.kill()
but this just gives me exit code 0, and no output.