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.

If you type echo -e '\eZ' and hit return in a shell running in an xterm, you'll see that the terminal emulator prints an obscure code 1;2c. This seems to indicate that xterm interprets the VT100 control sequence \eZ (ESC Z, return terminal ID) and acts accordingly.

Now, if you press ESC Z in the same console, nothing happens. Does this mean that it is not possible to send control characters directly using the keyboard?

I'm not sure what is happening here, because pressing CTRL s (control flow) does stop the console output until you press CTRL q. So why does CTRL s/q work and not ESC Z?

share|improve this question
    
can you please mark the answer below as correct if you are satisfied with it? –  sindikat Apr 5 '12 at 9:55

2 Answers 2

VT100s responded to character sequences sent to them as output. So echo'ing characters works because the terminal sees it as output. Typing characters is input; the terminal will respond only if the characters are echoed by the receiving computer. Your typical shell doesn't echo ESC, it interprets ESC as the prefix for some interactive input command. Run cat and type ESC Z RETURN and you'll see the usual VT100 response.

share|improve this answer
    
Thanks for the explanation. It makes sense. –  Ernest Feb 12 '12 at 22:22

Also, you can press CTL-V on the keyboard usually first to tell the terminal that you want it to pass an ESC directly in instead of using it. Of course, you still have to get it echoed back to you, so doesn't necessarily help in this case, but instances where, say, you're editing a file in VIM and want to include an escape code, that's a convenient way to do so.

share|improve this answer
1  
True, but this isn't what the question is about. The question asks how to send a command to the terminal, not how to input a control character literally. –  Gilles Aug 16 '12 at 17:57

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.