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`
質問
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
解決
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`
他のヒント
$ 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.
centos will print out your string in the console you select
#run on pts/8
[root@C203-ATC ONT]# uname -a
Linux C203-ATC 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@C203-ATC ONT]# echo "test" > /dev/pts/3
[root@C203-ATC ONT]#
[root@C203-ATC BASIC]# tty
/dev/pts/3
#checked on pts/3
[root@C203-ATC BASIC]# test
(cursor)
#cursor pending ...
You cannot do it like that.
The '>' redirection operator makes it so that for the WHOLE execution time standard input IS the echo
command, and you can't just change it later.
You might want to rethink your needs and implementation.