Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Python Running external programs

$
0
0
I have been searching for python docs relating to using python to control external programs read their input and pass them onto other programs. I may be using the wrong search terms due to my lack of knowledge but I keep retrieving information on reading and writing files.

The best result so far was for a python module called pexpect http://www.noah.org/wiki/Pexpect . It has a module script.py which can
script.py 
This implements a command similar to the classic BSD "script" command. This will start a subshell and log all input and output to a file. This demonstrates the interact() method of Pexpect. 



Other than that I found some code examples like this.
import subprocess, os

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

p.stdin.write("10")
#p.stdin.flush()
p.stdin.write("\r") #This might be unecessary
#p.stdin.flush()
p.stdin.write("\n")
#p.stdin.flush()

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


So from that i determine that subprocess is the best docs to review?
http://docs.python.org/2/library/subprocess.html

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>