import subprocess
import threading
import StringIO
class terminal(threading.Thread):
def run(self):
self.prompt()
def prompt(self):
x = True
while x:
command = raw_input(':')
x = self.interpret(command)
def interpret(self,command):
if command == 'exit':
return False
else:
print 'Invalid Command'
return True
class test(threading.Thread):
command = 'java -jar ../bukkit/craftbukkit.jar'
test = StringIO.StringIO()
p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while (p.poll() == None):
line = p.stderr.readline()
if not line: break
print line.strip()
term = terminal()
testcl = test()
term.start()
testcl.start()
This runs without error, however when running you cant type any input at the prompt. No characters or returns the user types appear, but the output of the running jar prints. What i'm looking for this to do is take input in the terminal class, process it, and feed output into the running java program. After scouring the internet all I found is subprocess.Popen(), but i cant figure out the stdin-out-err redirection. How would i solve this problem using Popen, or maybe a completely different method