A lot of people log into the same AIX 6.1 server as I do with a terminal emulator that automatically interprets and runs code encapsulated by certain control characters as VBA script instead of writing it to the display. So as a prank, I have a file that contains a sequence of characters that displays a message in a popup box that I want to write to their terminals.

$ cat msgbox.txt  
*message box pops up*

But when I write it to someone, the effect is lost:

$ cat msgbox.txt | write *my other sesssion*

On the other session:
Message from *myself* [*datetime*] \o 33 *code to show a msgbox* \o 33\<EOT>

Where the "\o 33" replaces ASCII character 27. Is it possible to send control characters through write, or do I need to do something different?

  • 1
    You also need to wear gauntlets to defend against those of us who will break your fingers afterward. – geekosaur Apr 25 '12 at 21:58

I don't know specifically about AIX, but on most unices, you cannot do this, by design. You can't read or write on other people's terminals, what happens there is none of your business. The write program has extra privileges (setuid root, or setgid tty, depending on the system). It takes care to sanitize the input you throw at it so as not to disrupt the other person too much.

If you really want to send control characters to a user's terminal, you need to be root.


You would need to cat it directly to the tty/pty device they're using. You would also need to make sure their terminal does the same thing yours does with the characters; you might need to watch out for the tty mode (beware of newline expansion).

  • I don't have permissions to do that. That is why I need to use some program like write. – harmless prankster Apr 25 '12 at 22:10
  • 1
    You do, actually; if write works, cat to the correct device node will. write just automates finding the device node from utmp, sanitizes, and adds a header. – geekosaur Apr 25 '12 at 22:15
  • When I try to cat to the device, I get "bash: /dev/pts/3: The file access permissions do not allow the specified action." But when I write, it works. What am I doing wrong? – harmless prankster Apr 25 '12 at 22:22
  • @geekosaur, on my system, write is setgid tty, so it's not necessarily true that if write works it means you have permissions to use cat. (Although my system is Linux; I don't know about AIX's write.) – cjm Apr 26 '12 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.