I'm writing a little curses program and I want to redirect stderr to another terminal. However, the only way of determining the correct /dev/pts/X device to redirect to that I know of is to echo text to them one at a time until it shows up where I want.Is there a command which will give me what I'm looking for?
How can I easily determine which pseudo-terminal device a terminal emulator has been assigned?
terminal
You are looking for the tty command, which prints the file name of the terminal connected to standard input.