I am trying to output different information in two terminals from the same Python script (much like this fellow). The way that my research has seemed to point to is to open
This doesn't work because you pipe stuff to xterm
itself not the program running inside xterm
. Consider using named pipes:
import os
from subprocess import Popen, PIPE
import time
PIPE_PATH = "/tmp/my_pipe"
if not os.path.exists(PIPE_PATH):
os.mkfifo(PIPE_PATH)
Popen(['xterm', '-e', 'tail -f %s' % PIPE_PATH])
for _ in range(5):
with open(PIPE_PATH, "w") as p:
p.write("Hello world!\n")
time.sleep(1)