How can I quit when connected via telnet?

21,417

Solution 1

$ telnet askubuntu.com 80
Trying 151.101.1.69...
Connected to askubuntu.com.
Escape character is '^]'.

That last line is the clue. Control+] busts you back to the main telnet prompt. From there you can run quit or Control+D to exit.

That said, throwing a load of rubbish at the Ask Ubuntu server (like a pile of ^Cs, followed by Return) does still see the server respond (by closing the connection).

$ telnet askubuntu.com 80
Trying 151.101.129.69...
Connected to askubuntu.com.
Escape character is '^]'.
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C

Connection closed by foreign host.

What you're describing makes it sound like that isn't the case. If that's really the situation, I'd load another terminal and killall telnet (assuming no other sessions you want to preserve), or just close the terminal emulator you'd been running this in and make a new one.

Solution 2

Given what you are trying to do the best way is

$ telnet askubuntu.com 80
Trying 151.101.129.69...
Connected to askubuntu.com.
Escape character is '^]'.
GET /path/to/whatever HTTP/1.1
Host: askubuntu.com
Connection: close

HTTP/1.1 200 OK ...

<HTML><HEAD> ...
</BODY></HTML>
Connection closed by foreign host
$

You probably won't see your side of the conversation when you type it in and if you're like me you make a lot of typos and there's no way to fix them; but when you go to make the here script that problem won't exist.

Share:
21,417
melic
Author by

melic

Updated on September 18, 2022

Comments

  • melic
    melic over 1 year

    I have a telnet connection through askubuntu.com 80 while trying to test cli based webbrowsing for github project. I got my connection established over port 80 but now I cannot do anything, even quit. Is there a way to quit this kind of connection? CTRL+c is not working and neither is any other key combination.

    Closing the tab may be the answer but this is not I want because I am planning to run a script over telnet and I do not want to install any browser like lynx or anything else. I want to use only the default programs we have in Ubuntu.

  • melic
    melic over 6 years
    so the only way to quit is quitting terminal no any other options or command ?
  • melic
    melic over 6 years
    ahh CTRL + ALTGR +] worked for me !
  • wizzwizz4
    wizzwizz4 over 6 years
    Note that ^] is ESC (the character, not necessarily the key).
  • deltab
    deltab over 6 years
    The character ESC is Ctrl+[, not Ctrl+]. The latter is an escape in the sense that it tells Telnet to pause its usual behaviour of sending anything you type through to the remote computer, and to instead process what follows as a command to the local Telnet program itself.