2

I'd like to get the value of the current xterm window's psuedo terminal, for use in the "write" function. For instance, when I type ps I can see that all the current processes are on pts/4. Is there a better way to get "pts/4" other than grep on the output of "ps"?

Eyal

Eyal
  • 21

2 Answers2

2

The command tty will "Print the file name of the terminal connected to standard input."

write username $(tty)
0

I think you can use /dev/tty which is the controlling terminal for the running process. If you need to find the tty which is connected to stdin, check the sources for /usr/bin/tty.