link between python and the windows command prompt

Y

yadin

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?
 
L

Larry Bates

yadin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,314
Latest member
HugoKeogh

Latest Threads

Top