2

I put a simple echo command in a CLI tty by user1 expecting it to reach user2 who is logged in a separate tty.

echo "Hello, world!" >> /dev/tty5

I expected user2 to get the echo message but nothing shows up.

Does each user get his/her own "set" of tty[1-7]?

Edit: I suspect this may be a permissions issue. I was actually exploring cron jobs and had set a cron job to echo a "hello world" message every minute from user1 logged into tty2 directed to tty5 where user2 is logged in but user2 never got the echoed messages.

haziz
  • 2,231
  • 4
  • 26
  • 37
  • 1
    No. See [construct-a-command-by-putting-a-string-into-a-tty](http://unix.stackexchange.com/questions/48103/construct-a-command-by-putting-a-string-into-a-tty/48120). –  Dec 30 '12 at 19:12
  • 4
    Have a look at the `write` command. That's more along the line of what you want. – Max Dec 30 '12 at 19:24
  • What shell are you using? Did you get any error message? What is the output of `echo "Hello, world!" >> /dev/tty5; echo $?`? – Gilles 'SO- stop being evil' Dec 30 '12 at 23:44
  • @Gilles It's Bash for both users. System is a Centos 6.3 installation. – haziz Dec 31 '12 at 01:12

1 Answers1

2

If user2 is logged into tty5, he is the owner of /dev/tty5. If he has messaging enabled, then you can send him a message using write user2, but if he doesn't, you're out of luck unless you are root. echo "Hello, world!" >> /dev/tty5 only works if executed by root or by user2.

cpast
  • 328
  • 2
  • 9