os.system issues

rdmurray at bitdance.com rdmurray at bitdance.com
Thu Feb 5 09:14:55 EST 2009


Youri Lammers <youri_lammers_88 at hotmail.com> writes:
> I want to run a program called 'muscle' with my python script=2C
> muscle uses the following command:
> 'muscle.exe -in filename -out filename'
> so far I got:
> 
> import os
> args = ['-in filename', '-out filename']
> os.system('E:\Programs\muscle\muscle.exe args')
> 
> However when I run this nothing happends no error message nothing.
> 
> So what am I doing wrong here?

You are calling the program muscle with the argument 'args'.

If you want to put your arguments into the system call, you will
want to write it like this:

os.system('E:\Programs\muscle\muscle.exe -in filename -out filename')

If you need to substitute args into the string passed to
os.system, then take a look at python string handling in the
tutorial.

You also will probably want to look at the 'subprocess' module
at some point, which is more flexible than os.system.

--RDM




More information about the Python-list mailing list