When I execute a command like:
echo "Hello" > tty/pts/2
It will print the message on that
terminal. Is it redirected to
stderr of that
Presumably your command is not right; As it stands it will save the string "Hello" to a file named
tty/pts/2 (if the intermediate directories exist).
Perhaps you meant:
echo "Hello" > /dev/pts/2
which will send the string "Hello" to the 2nd pseudo terminal.
Now, the STDIN, STDOUT and STDERR of the process running inside the terminal are bound to the pseudo terminal itself, so it is not really possible to single out the file descriptor of the process running within the terminal.
You can check that in
/proc, by reading the file descriptor the shell that is running within a terminal, you will see that the standard streams are actually symlinked to the pseudo terminal.
zsh runing on pseudo terminal
/proc/self/fd% tty /dev/pts/46 /proc/self/fd% ls -l lrwx------ 1 foobar foobar 64 Jun 13 15:07 0 -> /dev/pts/46 lrwx------ 1 foobar foobar 64 Jun 13 15:07 1 -> /dev/pts/46 lrwx------ 1 foobar foobar 64 Jun 13 15:07 2 -> /dev/pts/46
Simple test would be redirect
stdout and then
stderr of the command to
/dev/null and see what happens.
adminx@L455D:~$ echo "hello" > /dev/pts/22 hello adminx@L455D:~$ echo "hello" > /dev/pts/22 > /dev/null # no output , stdout gone adminx@L455D:~$ echo "hello" > /dev/pts/22 2> /dev/null # stderr gone, but stdout shows up hello
stdout is what you see.
stderr have meaning only when bound to processes.