For example, if I have this code:
Is it possible to have python output strings to that specific terminal that was just opened? Thanks!Answer1:
Possibly, but it is easier to have a custom process running in the subordinate terminal. For example, given
sserv.py from the <a href="http://docs.python.org/library/socketserver.html#socketserver-tcp-server-example" rel="nofollow">example server in the documentation</a> the command:
gnome-terminal -e "python ./sserv.py"
will happily chat on port 9999 with you. Given a more complex
sserv.py it could do anything you want (anything terminalish, that is).
I think that <a href="http://www.noah.org/wiki/Pexpect" rel="nofollow">PExpect</a> might do this for you:<blockquote>
Pexpect is basically a pattern
matching system. It runs programs and
watches output. When output matches a
given pattern Pexpect can respond as
if a human were typing responses.
Pexpect can be used for automation,
testing, and screen scraping. Pexpect
can be used for automating interactive
console applications such as ssh, ftp,
passwd, telnet, etc. It can also be
used to control web applications via
w3m, or some other
text-based web browser. Pexpect is
pure Python. Unlike other Expect-like
modules for Python Pexpect does not
require TCL or Expect nor does it
require C extensions to be compiled.
It should work on any platform that
supports the standard Python pty