I am trying to write a script to open a third-party console application and run commands on Windows. The third-party console requires the two commands; 'connect' and 'run'. A typical input/output is shown below. This connects to the host server then runs a process indexed by three parameters (p1,p2,p3).
>connect server
Successfully connected to service.
>run p1 p2 p3
Successfully started.
FINISHED
The app does not allow me to execute both commands in one line using & as with cmd.
Despite reading the subprocess documentation I can't figure out how to pass my two commands into the executable.
I am using Python 3.5, so I believe subprocess.run should be suitable for this task. The snippet below simply opens the third-party console. I have tried other code, linked at the bottom of the post, but I am unsure how to implement it for my purpose.
import subprocess
exe = r'C:\...\third_party_app.exe'
subprocess.run(exe)
Below are some of the SO resources that could be helpful that I have tried, and failed, to interpret.
https://stackoverflow.com/tags/subprocess/info
Python - How do I pass a string into subprocess.Popen (using the stdin argument)?