Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

write username $(tty)
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.