Pablo
Pablo

Reputation: 29519

How to redirect output of Python script to terminal

How can I redirect my Python script output to one of the open terminal windows under Ubuntu? The script is spawned by KMail filtering rule.

Upvotes: 0

Views: 1016

Answers (1)

David Wolever
David Wolever

Reputation: 154454

Creating a simple socket server would be one method… But I'd probably use fifos:

$ mkfifo /tmp/my_fifo
$ cat producer.py
f = open("/tmp/my_fifo", "w")
f.write("hello, world!\n")
f.close()

Then you could read from it using cat /tmp/my_fifo

Or a simple log file:

$ cat producer.py
f = open("/tmp/my_log", "a")
f.write("hello, world!\n")
f.close()

Then you could read from it using tail -f /tmp/my_log

Upvotes: 1

Related Questions