Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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.