Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I echo to /dev/tty?

Is there a way to send something like an "end of data" after executing

echo "test" > /dev/tty1

in order to gain the "input cursor" back to "receiving" terminal (in this case tty1)?

Screenshot: http://picload.org/image/acdwigg/tty.png

like image 484
inselberg Avatar asked Apr 18 '13 10:04

inselberg


People also ask

How do you dev tty?

/dev/tty stands for the controlling terminal (if any) for the current process. To find out which tty's are attached to which processes use the "ps -a" command at the shell prompt (command line). Look at the "tty" column. For the shell process you're in, /dev/tty is the terminal you are now using.

How do you echo something in shell script?

The echo command is used to display a line of text that is passed in as an argument. This is a bash command that is mostly used in shell scripts to output status to the screen or to a file.

What are dev tty files?

For each process, the /dev/tty special file is a synonym for the controlling terminal associated with that process. By directing messages to the tty file, application programs and shell sequences can ensure that the messages are written to the terminal even if output is redirected.


2 Answers

Using echo > /dev/tty you can't achieve that. But you can do that by sending a signal to process which are using that tty.

For example:

kill -s SIGINT `ps -ft pts/2 | grep pts/2 | cut -d ' ' -f 5`
like image 98
Reishin Avatar answered Oct 10 '22 22:10

Reishin


$ echo "test" > /dev/tty
test
Cygwin supports the following character devices commonly found on POSIX systems:

/dev/tty    The current controlling tty of a session.

Special filenames

like image 36
Zombo Avatar answered Oct 11 '22 00:10

Zombo