import subprocess,shlex
command = 'python mesh.py'
workingdirectory = 'C:users/Account/Desktop'
try:
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True, cwd=workingdirectory)
stdout, stderr = process.communicate()
if stderr.decode('utf-8') == "":
with open(outputlog.txt, 'w'):
file.write(stdout.decode('utf-8'))
else:
with open(errorlog.txt,'w') as file:
file.write(stderr.decode('utf-8'))
Create 2 empty text files named outputlog and errorlog in the working directory.
Use Shlex to build your command, Popen for IPC.