how to translate a cmd line to a os.system line?

238 views Asked by At

I used to run a program called vina through the cmd line using the following command:

"\Program Files (x86)\The Scripps Research Institute\Vina\vina.exe" --config conf.txt --log log.txt

So, the program takes the config file to run and outputs a log file with the results. I am running the program in python using the os.system module. However, I can't assign the config file or the log file as I did in the cmd. I tried something like this in python:

os.system('C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe' --config conf.txt --log log.txt)

The program opens real quick then closes, maybe because it doesn't run the config file. I have also tried putting the config into a string as follows (I am omiting the log thing until I get the config to work):

os.system('C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe', '--config conf.txt')

In this case I get the error:

TypeError: system() takes at most 1 argument (2 given)

Any ideas on how to specify the config file and the log file output in python lines as I do in cmd?

2

There are 2 answers

1
Richard On BEST ANSWER

The correct syntax to replicate the command line command would be

os.system('"C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe" --config conf.txt --log log.txt')

If that doesn't work, try specifying full paths for conf.txt and log.txt

0
Grigor Kolev On

os.system(r'"C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe" --config conf.txt --log log.txt')