I am trying to download a binary file from an HTTP server with GNU Telnet, a tar archive to be exact. I can currently download regular files, but I can't properly redirect the output to a file. The only thing I have tried so far is

(echo 'GET /'; echo; sleep 1; ) | telnet mywebsite.com 80

(Source). It works, but redirecting the output with > filename also includes the telnet information:

Connected to mywebsite.com.
Escape character is '^]'.

How do I get the telnet output with only the data and not the connection and disconnection information?

EDIT: I just compiled curl without OpenSSL support and I'm using it instead, so I am not using telnet anymore.

1 Answer 1


Use a proper tool. Curl and wget do everything you need, they are written to do it reliably and every distro includes them.

  • I know, the reason I need to use telnet is I don't have any other option. You see, I'm trying to make a script that creates a macOS jail that is as small as possible, and using curl requires copying libraries that are in total over 5 GBs. Actually, I just got an idea, I'll try compiling curl myself, without openssl.
    – user309914
    Commented Sep 11, 2018 at 17:24
  • Compiled curl without openssl and it works.
    – user309914
    Commented Sep 11, 2018 at 18:25
  • That's a very ingenious solution! Commented Sep 11, 2018 at 20:26
  • I couldn't get curl working before asking this question, and for some reason your answer gave me the idea to build without openssl. Yeah, not an answer to my question, but an answer to my problem. Also, why no openssl? Because openssl is the whole problem. It requires a lot of libraries to copy to the chroot jail.
    – user309914
    Commented Sep 11, 2018 at 20:29
  • Didn't know that openssl was the problem. A simple http fetch program written in C might even be an option. I found one at lemoda.net/c/fetch-web-page which looks simple enough. Didn't check its safety though. Commented Sep 11, 2018 at 20:34

You must log in to answer this question.