p = subprocess.Popen('cmd', stdin=subprocess.PIPE, stout=subprocess.PIPE,
    stderr=subprocess.PIPE, shell=False, universal_newlines=True)
outQueue = Queue()
errQueue = Queue()
outThread = Thread(target=enqueue_output, args=(p.stdout, outQueue))
errThread = Thread(target=enqueue_output, args=(p.stderr, errQueue))
outThread.daemon = True
errThread.daemon = True
outThread.start()
errThread.start()
someInput = input('Input: ')
p.stdin.write(someInput)
errors = getOutput(errQueue)
output = getOutput(outQueue)
Запуск интерактивной команды из Python