For now i have some Command-Line Interface which one i need to interact. (e.g. run this CLI in terminal, then execute few comands inside of it). In terminal it looks the next way:
blabla-cli
some-comand
%response%
next-command
And all of it i want to automate with python.
Almost all what i could fing in the Google is about using Popen
and comunicate
or process.stdin
to do what i want.
But in case of using provided code i can't send any comand to process, i mean "help" wont be sended to terminal
args = ["blabla-cli"]
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
process.wait()
process.stdin.writelines('help')
process.wait()
print(process.stdout.readlines())
I expect to send some command to terminal via python code, get some response and get some actions with recieved response.