I don't think you want to be using
os.system()
. That's alright if what you're doing is running a command, and you don't really care what the output of that command is, or you don't want to interact with it.
You do want to interact with it. So I think you should try the subprocess module:
https://docs.python.org/3/library/subprocess.html
Using stdin=PIPE and stdout=PIPE, you can communicate with the external process and send commands to it.
You can also look into the
pexpect
module, though that isn't built into python.
https://pexpect.readthedocs.io/en/stable/