Create a new terminal / shell window to display plain text

I want to pipe [edit: live text] the output of multiple sub-processes (sometimes linked, sometimes parallel) to a single terminal / tty window that is not an active python shell (be it an IDE, command line, or running a script using tkinter). IPython is not an option. I need something that comes with a standard installation. Prefer OS agnostic solution, but need to work with XP / Vista.

I'll post what I've already tried in case you want it, but its awkward.

+1


a source to share


3 answers


A good Unix solution would be called a pipe. I know you asked about Windows, but there might be a similar approach on Windows, or it might be helpful for someone else.

on terminal 1:

mkfifo /tmp/display_data
myapp >> /tmp/display_data

      



on terminal 2 (bash):

tail -f /tmp/display_data

      

Edit : Modified terminal 2 command to use "tail -f" instead of endless loop.

+2


a source


You say pipe, so I am assuming you are dealing with textual output from subprocesses. A simple solution might be to just write the output to files?

eg. in subprocess:

  • Redirecting output %TEMP%\output.txt

  • On exit, copy output.txt

    to the directory your main process is looking at.


In the main process:

  • Study the directory every second for new files.
  • When the files are found, process and delete them.

You can encode the subprocess name in the output file name so you know how to handle it.

0


a source


You can create a manufacturer-customer system where strings are inserted above the socket (nothing interesting here). The client will be a multithreaded socket server listening for connections and putting all lines in the Queue . In a separate thread, it will receive items from the queue and print them to the console. The program can be run from the cmd console or from the eclipse console as an external tool without too much trouble.

From your point of view, it should be in real time. As a bonus, you can place manufacturers and customers on separate boxes. Manufacturers can even create a network.

Some examples of socket programming with python can be found here . Look here for an example tcp echoserver and here for a "hello world" tcp socket client.

There is also an extension for windows that allows named pipes.

On linux (cygwin perhaps?) You could just tail -f named-fifo.

Good luck!

0


a source







All Articles