Coding/Python Matlab

파이썬 - 외부 프로그램 실행

smores 2012. 10. 12. 03:21
print os.system('example.exe')



# when we need to exchange std in/out

import subprocess, os
import time

PIPE = subprocess.PIPE
p = subprocess.Popen("example.exe", stdin=PIPE, stdout=PIPE)

p.stdin.write("10")
time.sleep(0.1) # or p.wait(), without this line, deadlock happens
p.stdin.flush()
print p.stdout.read() #Deadlock

print "End of Execution"
os.system("PAUSE")