Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
add comment

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).

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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