I am using python 3.3 and in my code I need something to open cmd.exe with the following arguments and run it. The desired line in cmd.exe should be:
C:\Program Files (x86)\GlobalMapper15>global_mapper.exe script.gms variable
I saw different answers but the most I managed with subprocess.call is to open either cmd.exe, or global_mapper.exe. I did not manage to obtain the line above in cmd.exe.
I tried so far:
#import subprocess
import os
os.system("cmd.exe C:\Program Files (x86)\GlobalMapper15\global_mapper.exe script.gms")
#subprocess.call(["cmd.exe C:\Program Files (x86)\GlobalMapper15\global_mapper.exe", "script.gms"])
Neither of them worked well.
Of course, it would be great if the line would be also executed. Can anyone help me make this happen?
Thank you all,
To run global_mapper.exe in given directory:
#!/usr/bin/env python
from subprocess import call
dir = r"C:\Program Files (x86)\GlobalMapper15"
cmdline = "global_mapper.exe script.gms variable"
rc = call(cmdline, cwd=dir) # run `cmdline` in `dir`
If you want to start the command in a new console window:
rc = call("start cmd /K " + cmdline, cwd=dir, shell=True)
maybe with this:
import os
os.system("program.exe -parameter")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With