os.system deprecated. The right thing to do is Wyrmwood mentioned by Popen , and separate the arguments:
import subprocess subprocess.Popen([ "C:\Program Files\SumatraPDF\SumatraPDF.exe", "-page", "5", "D:\Dropbox\Final Term\Final Draft.pdf" ])
You can then create your team by specifying a list and .extend with your arguments. You can add ( + ) sys.argv to take from the command line, etc.
There are other useful functions in subprocess that allow you, for example, to get output from a command ( checkoutput ). You probably just want subprocess.call .
If you use plain process = subprocess.Popen(...) , be prepared to call process.wait() to prevent premature termination.
source share