link between python and the windows command prompt

Larry Bates larry.bates at websafe.com
Mon Jul 23 21:23:38 CEST 2007


yadin wrote:
> hi! i need to know how i can run ussal commands that i ussally type at
> the windows command prompt from a python file. that is  for example
> from the windows command prompt i ussually type "cd D:\folder\ nec2++ -
> i inputfile.nec -o outputfile.out "  now how can i execute this
> command that i ussually type at the windows command prompt from a
> python file?
> i know it has to do with the sys and os module but how specifically?
> what commands? any references?
> 
You can use os.system or if your needs are more complex, take a look at the
subprocess module.

import os
import sys

os.chdir('D:\\folder')
os.system('D:\\nec2++ -i inputfile.new -o outputfile.out')

-Larry



More information about the Python-list mailing list