Hello,
From Python, I need to run a couple of command-line apps in Windows.
Is this the right way to do it, including how to tell if the apps ran successfully?
Thank you.
From Python, I need to run a couple of command-line apps in Windows.
Is this the right way to do it, including how to tell if the apps ran successfully?
Thank you.
import subprocess
import shlex
URL = r"http://www.acme.com"
my_command = fr"C:\acme.exe {URL}"
my_cmd = shlex.split(my_command)
p = subprocess.Popen(my_cmd, stdout=subprocess.PIPE, text=True)
while (line := p.stdout.readline()) != "":
pass
print(f"End of output. Return code: {p.wait()}")
#TODO handle success/error
