-2

I have a python project that I use curses. I would like to open another shell for piping some of my outputs, how shall I achieve this?

Clarification:

I am writing a TUI using Curses module of python. Therefore my initial bash shell is a curses window.

I would like to have live updated variables in another bash shell if that's possible for debugging purposes.

What I am asking is, if there is a way to make a python program open another shell and pipe the standard output to that shell, instead of the default shell which in my case is the window for the curses environment.

1 Answers1

1

A couple of possibilities.


Start a second Terminal window, and in there run:

tty
/dev/ttys000       # sample output - note down for next command

In the first Terminal where you run curses, do:

echo "Hi" > /dev/ttys000

Alternative method... make a fifo with:

mkfifo fifo

In a second, new Terminal, run:

while : ; do cat fifo; done

In the first Terminal, run:

echo "Hi" > fifo

Alternative method... tail a file.

In your curses Terminal, append messages to a file:

echo "Message" >> log.txt

In your other Terminal, follow the tail of the log file:

tail -f log.txt
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432