Yeah, I think you misunderstood my question.
Let's say I'm running my script while logged into TTY2. No one is logged into TTY1. So from my script running on TTY2, I want to send messages (whether they be debug, errors or just informational) to TTY1.
Now the TTY's already exists as set up in my inittab:
Code:
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
And the char devs are for the TTY's are listed in /dev but belong to root.
Now when I try to send a message from TTY2 to TTY1 (remember no one is logged into TTY1):
Code:
echo "my message" >/dev/tty1
I get the permission denied error.
Since I posted, I've checked and found that the error is occurring because the character device tty1 belongs to root and I'm trying to write to it as a normal user.
If I issue the above command as root, the message is printed on TTY1.
Now I realize that I can change the owner of TTY1 to that of the user running the script, send the message to TTY1 and then reset the owner of TTY1 to root. I'm not sure this is the best way security wise. There must be a more elegant solution.