The text adventure game of exiting a Telnet session
ma.ttias.be
ma.ttias.be
Back in the early 90s the local university used to have a free dial-up that you'd connect to via modem and then could telnet anywhere. You didn't need to be a student or anything. As a teenager I used this to connect to various shell accounts I had around, and to various MUDs. (This was in the pre-ISP days -- there was nobody in my area offering dial-up Internet at all.)
At some point they pulled this and made it for students only. But they had a dial-up gopher service for campus information and library access that was actually a telnet session to a gopher client on a SunOS machine somewhere.
But they didn't disable the telnet escape character.
So for a few months back then the way I got Internet access was to dial into the gopher client, hit ^], close the session to the gopher client, and open to anywhere else I chose. Eventually they closed this hole, too, but it was glorious for a while.
So, thanks telnet!
Apache won't serve certain files unless the permissions are just so, and he could not get them to fix them or give him a shell to do it himself. So he couldn't do his job.
I ended up telling him about the shell escape trick.
He was having a rough time, and nobody wanted to be the one to tell him he was going to be kicked by association, so it was lucky we had a workaround.
The sort of people who could do that back then generally had much better things to do with their time. And resources. When you’re dealing with idiots who only have access to dialup or their university computer lab, it doesn’t take much to stop them. It was just a bunch of 20 year olds trying to have fun. Not defense networks.
Was this, by chance, a .umn.edu dialup ?
Just curious ...
Another key thing to know, is that old pre-PS/2 keyboards actually emit these ASCII symbols, or something like them, directly, when you hit the appropriate key; and also do the appropriate Control-masking in hardware. When you hit the Backspace key on an IBM Model-M keyboard, it's sending 0x08 down the line. When you hit Control+H, it's also sending 0x08 down the line. The computer receiving these can't tell the difference (and, in fact, does not receive KeyDown/KeyUp signals for the Control key. It's not a "key" as such.)
And so, what's happening with the author's "cheat sheet", is that there's some particular key on these keyboards that has 0x5D ']' as its scancode; and, despite modern keyboards no longer doing Control-masking in hardware, the author's Terminal emulator is doing it in software, translating the key-chord of "the key with scancode 0x5D" + "control being held" into "the ASCII symbol 0x1D" (that's GS/Group Separator, for those wondering) and emitting that octet through the TTY driver into the telnet client, which receives it and treats it indistinguishably from someone who had typed Control+] on a US 101-key keyboard.
Then the `tmux` dude goes on and uses `C` instead of `^` [0]. God that was hard to figure out. But it gets worse: he continues to describe it as `C` even when he's not actually meaning _control_. No, that's just the _default_. He actually means `C` to mean whatever was bound to the configured "meta control". Uhh, at least, that's my understanding of it right now.
Tmux author (if you read this): I still haven't figured out why your software can't redraw lines. I'm continuously seeing garbled nonsense on the session from software clearing a line but tmux not actually clearing that line. `htop` works and looks great outside of tmux but inside of it? Oh god I can't read anything at all because it's all garbled.
But yeah, after learning that `^` means "press control", getting out of Telnet was eas....oh man I'm stuck in telnet stil.. Halp
That notation comes from Emacs. For example, see
https://www.emacswiki.org/emacs/EmacsNewbieKeyReference
Because of the Emacs focus on modifier keys, there is a joke that it stands for "Escape Meta Alt Control Shift".
[0]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Ke...
So "C" is the letter C, "C-x" is ctrl-x, "C-c" is Ctrl-c, and there's no ambiguity. You can't bind anything to Ctrl on its own.
Be careful with your terminology, meta is a key too. https://en.wikipedia.org/wiki/Meta_key
control, meta, super, and hyper.
But „Greek“ is what I really want.and those Roman numerals are also quite pretty.
Wait that page says nothing about tmux!
I work in terminals all day long at home and work. I have a consistent user profile. On the other hand different operating systems have different terminals. I've seen the symptom occur locally (Ubuntu -> Gnome-Terminal -> bash -> tmux) and usually go away after an update of one of the components. But most frequently it occurs when crossing boundaries ({Windows, Fedora, Ubuntu} | {putty,gnome-terminal,tilix,serial tty} | tmux | literally anything). It happens more frequently when embedding tmux sessions while crossing those boundaries.
I _really_ wish there existed some software which would try to debug terminal display issues, even if it involved echoing something in a client program and then asking me "does this show up as intended and/or garbled?", with a timeout value for "it's so garbled that the user couldn't read or respond" similar to configuring a video display.
* https://invisible-island.net/ncurses/ncurses.faq.html#xterm_...
* http://jdebp.uk./Softwares/nosh/guide/commands/TERM.xml#MIS-...
* https://unix.stackexchange.com/a/419092/5132
* https://unix.stackexchange.com/a/446912/5132
* https://unix.stackexchange.com/a/515517/5132
* https://unix.stackexchange.com/a/427299/5132
today I learned an assumption I made is wildly inaccurate. Thanks, now I need to go re-evaluate my terminal choices
luckily it's a weekend
I've used "^" for "Control" for at least 40 years.
And more confusing is that these days "C-x" is supposed to mean "Control X." But since I'm used to Control being ^, I read it as "Control-minus, followed by x."
My first foray into vi on an ancient Unix as opposed to Vim on Linux led to my manager at the time coming up behind me, startling the crap out of me and saying, "beep beep, what? You OK?".
Rather embarrassing actually...
The defacto ed tutorial exactly predicts/describes my first encounter:
golem$ ed
?
help
?
?
?
quit
?
exit
?
bye
?
hello?
?
eat flaming death
?
^C
?
^C
?
^D
?
Note the consistent user interface and error reportage. Ed is generous enough to flag errors, yet prudent enough not to overwhelm the novice with verbosity.From the same site, the source code of ed:
while :;do read x;echo \?;done
Netcat (based on the old Hobbit code) or nmap’s ncat are pretty universally installed. It just opens a socket and lets you type away until EOF (^D). Or you can just do “nc -v host port < /dev/null” (or just do ”-z” for non-ncat). Hilariously my phone doesn’t have backticks for me to denote those as commands.
It's just that telnet seems to be more universally installed in my experience. (arch linux for example)
From image searches, it looks like Apple only print @.
Typical Apple form-over-function.
I find this interesting, because back in the 90's I happened to be in Austria and I bought a German keyboard for the sole reason that it had all of the brackets on it, and the US keyboard I was using at the time didn't.
Keyboards can be so random. I wonder what goes into these kinds of decisions amongst keyboard designers. (I know there's an ISO committee for this, but we all know "standard" ≠ "best")
"My keyboard doesn’t have a ] sign on it."
Which leads to the following question (for future language designers)...
How do developers in foreign countries, using keyboards with no '[' or ']' symbols on them, type square brackets '[]' for array notation, when they are using arrays, in any programming language that requires brackets for array notation?
?
https://en.wikipedia.org/wiki/Digraphs_and_trigraphs
For example, in C, ??( is [ and ??) is ] which isn't so bad, but then there's this:
// Will the next line be executed????????????????/
a++;
The answer is no, it won't, because ??/ is \ which means the next line gets pasted onto the end of the previous one, which is commented out.But this all goes back to ALGOL, which had some important digraphs:
> Early versions of ALGOL predated the standardized ASCII and EBCDIC character sets, and were typically implemented using a manufacturer-specific six-bit character code. A number of ALGOL operations either lacked codepoints in the available character set or were not supported by peripherals, leading to a number of substitutions including := for ← (assignment) and >= for ≥ (greater than or equal).
On the Swedish layout, for example, [] are typed using Alt Gr (i.e. right alt) + 8/9. I know a few developers who use an English keyboard layout when programming, just to avoid contorting their hands for these awkward key combinations.
The first and last are actually diacritics, so you have to press once, then press the space bar. We don't even have back diacritics in Spanish.
Otherwise, I guess I'd do something terrible like break out an engraving tool...
Many English-keyboard-owners can't type "6°C" correctly, or "6000cm³", so I can't say Belgium's standard is worse.
° is Compose, o, o.
³ is Compose, ^, 3.
€ is Compose, C, =.
— is Compose, -, -, -.
Ê is Compose, ^, E.
There are hundreds of reasonably guessable combinations.
alt ( for the curly bracket
alt-shift ( for the square one
A ton of special characters are accessible this way
https://the-little-locket-blog.tumblr.com/post/115916807689/...
Azerty is pretty much the default in the non-IT world in Belgium. But, as for software engineering, everywhere I worked though they asked if I wanted qwerty or azerty layout on my machines.
I'd also recommend switching to qwerty as it's just more natural for programming than azerty. Plus I got up to speed (~130wpm) after just a few weeks of using it, so it's not a huge effort either.
On Linux, when I remap the keyboard to Belgian (setxkbmap be), typing ] is done with AltGr+the-key-two-to-the-right-of-P. At least on PC keyboards, ] is printed on this key, on the right as is usual for AltGr combinations. Exiting telnet is done with Control+AltGr+the-key-two-to-the-right-of-P.
When I set it to Danish, typing ] is done with AltGr+9, and exiting telnet is done with Control+AltGr+9. ] is also printed on this key.
Why is Mac confusingly different?
For testing:
telnet towel.blinkenlights.nl
Edit: if you think this is not a Mac-only issue, please elaborate...Edit: Here's the code: https://github.com/marado/netkit-telnet/blob/3f352877ee28cc4...
But it seems to have been basically abandoned so I have no idea how you get this into Debian.
Either that or Belgians need a modernized keyboard with easy keys for popular programming language chars.
I'm using a US intl no dead keys layout, and can easily type our Umlaute (actually much easier than {}[]).
There are indeed many programmers that use qwerty layout in belgium, but laptops with the ISO qwerty layout can be harder to get depending on the brand than azerty and convincing employers to buy one can be challenging.
Should be "Dutch (Belgian)" or "Belgian Dutch". In the Netherlands, no one has such a keyboard, or any AZERTY keyboard for that matter (apart from the occasional imported Belgian or French person), it's almost entirely US keyboards.
Apple for example doesn't include telnet by default anymore as it's considered insecure so I end up brew install inetutils on my machines.
Tilde, control-Z will do the trick: suspend the telnet process. Then
kill %1
kills the suspended telnet process.
(Along with the utility of force-closing connections, this is also why it can be surprisingly difficult to use SSH in situations where you want a low-privilege user to be able to access the shell of a remote system, but not immediately get up to crazy network shenanigans. SSH is actually too feature-rich for that use case, and this escape-character menu is an example of why; even if you somehow take control of the command line entirely, they can still start opening reverse forwards and doing a variety of other things. Very useful for reasonably privileged users, though.)
https://github.com/dspinellis/unix-history-repo/blob/usr/src...
https://en.wikipedia.org/wiki/End-of-Transmission_character#...
\n~. is for gracefully exiting a stuck/hung SSH session (e.g. one where the remote isn't responding to input) without force-killing the SSH client itself (which might do bad things to the process group it lives in.)
Being the least interesting programmer on Hacker News, I don't always write code to handle Telnet-compatible ASCII input, but when I do, I always support ^D.
The French language doesn't use the standard quotation mark to indicate dialogue, but I would still expect a French programmer to have a keyboard capable of producing one.
" and ' are on the standard French (and Belgian) keyboards.
In general on European keyboards, letters like ê, å, ç, ñ, ß are more useful, so some of the punctuation only of interest to programmers and mathematicians ([], {}, ^, #, |, \, `, ~, _) is accessed using the AltGr (right alt) key.
Usually, the AltGr symbol is printed on the bottom right of the key (Shift+AltGr symbols on the top right). Sometimes only some of these keys are printed -- typical British keyboards print € on the 4 key, but not á, é etc -- although (of course!) they still work.
And no, using the multinational US keyboard layout makes it even worse, it's not designed for daily multilingual use.
In all seriousness can't you just Ctrl+C or Ctrl+Z and kill the process instead? Maybe there's something that prevents this that I don't remember, my shell game is rusty.
If you have flailed around and messed with a file because when you type, it ignores your input until you use the 'i' character, suddenly you need to stop, close and reopen the file (because you don't know to hold the u key to undo). So, you do what works on DOS or nano, and hit Ctrl + C.
Someone coded it such that if you hit Ctrl + C to exit, instead of exiting out of VIM immediately, the editor writes a message that says "to exit vim, you must type :quit".
So you type that, and VIM responds with 'you have unsaved changes, please add ! to overwrite', so you type ! and it does nothing. After several seconds of confusion, you google how to get out of vim and the internet reveals the magic keystrokes ":q!" to finally get out of this dad blame file and get back to what you were doing.
All of that (probably, in my cynical mind) to avoid following the principle of least surprise and have Ctrl + C = close, discard changes.
Obviously this is a joke, but I have to admit that's usually my go to solution for those rare cases where I need to actually use telnet (to some tcp socket for debugging).
There are really only a few actual physical differences amongst Model M/Windows and workalike keyboards. (i.e. I am not talking about things like Maltron keyboards.) Those are the differences between 101/104, 102/105, 103/106, 104/107, and 106/109 key keyboards.
Ironically, that's really all that looking at the keys next to the shift keys gives one. The 102/105-key and 104/107-key keyboards add a key at B00, in between the left shift and B01. The 104/107-key and 106/109-key keyboards add a key at B11, in between the right shift and B10. So it's possible to detect the number of keys somewhat by seeing what USB HID codes come down the wire for "next to the shift key".
But this does not tell the computer anything about what is engraved on the keytops, and is not sufficient information for determining, say, Dvorak from AZERTY. (It's not even sufficient for detecting the 103/106-key keyboard, whose extra keys are on row A.)
I know that "media keys" (e.g. a Calculator button) aren't actually keys but another kind of USB HID device hanging out on the keyboard like a Touchpoint mouse; but F1-F12 keys really are keys, events sent from the same device that sends regular keysyms. Are they just random non-positional codes hiding out outside the ISO 9995 reserved range?
Control/shortcut keys are bound to the physical key, not to the regional layout characters bound to them. The displayed shortcut is often shown as the one for the US/UK layout.
As someone that often switches from US layout for programming to local layout for a few national characters, I'd consider any other behavior to be incorrect.
(People using QWERTZ/AZERTY might not agree/don't switch layouts that much. I'd be really annoyed if location for Ctrl+Z moved around... This is why standard key for Undo on PC was Alt+Backspace, which I still often use).
There's no reason that would have to change. If the OS was aware of both the key's physical location and what character it was supposed to represent it could easily keep the same physical mapping while simultaneously displaying the correct characters for that mapping.
Swedish keyboards don't have those dedicated keys either and it's always a dance of hitting a random option among ({[ when trying to type fast.