os.system not working, but typing the same thing into the command prompt works

Mark Gordon picture Mark Gordon · Mar 27, 2017 · Viewed 12.1k times · Source

I am trying to run python abaqus through the command prompt using

os.system('abaqus CAE noGUI=ODBMechens')

It doesn't seem to run anything, but if I go to the command prompt myself and type in

abaqus CAE noGUI=ODBMechens

it works. I am using python 2.7 on Windows 10. Thanks

Answer

Crt picture Crt · Mar 27, 2017

try using the subprocess module (it's newer) instead: for example,

subprocess.call(["ls", "-l"])

and in your example, it would be:

subprocess.call('abaqus CAE noGUI=ODBMechens')

More info on the difference between subprocess module and using os.system call:

The Difference between os.system and subprocess calls