18

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.

4
  • terminal askubuntu.com 80
    – melic
    Sep 8 '17 at 13:15
  • after a long period of inactivity connection is closed by foreign host but I just want to get connect run a script and as the result I will get some data. but I can not even make it by manuel
    – melic
    Sep 8 '17 at 13:16
  • 2
    You're welcome. I had the same problem watching Star Wars
    – Zanna
    Sep 8 '17 at 14:10
  • @Zanna Thanks a lot ; you made my day ! it was amazing ...
    – melic
    Sep 8 '17 at 14:41
33
$ 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.

4
  • so the only way to quit is quitting terminal no any other options or command ?
    – melic
    Sep 8 '17 at 13:33
  • 2
    ahh CTRL + ALTGR +] worked for me !
    – melic
    Sep 8 '17 at 13:34
  • 3
    Note that ^] is ESC (the character, not necessarily the key).
    – wizzwizz4
    Sep 8 '17 at 17:28
  • 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.
    – deltab
    Sep 9 '17 at 0:26
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.

0

You can use this command to quit telnet:

echo quit | telnet servername portnumber

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.