0

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:

Trying 1.2.3.4...
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.

5

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. – pixelomer Sep 11 '18 at 17:24
  • Compiled curl without openssl and it works. – pixelomer Sep 11 '18 at 18:25
  • That's a very ingenious solution! – Hans-Martin Mosner Sep 11 '18 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. – pixelomer Sep 11 '18 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. – Hans-Martin Mosner Sep 11 '18 at 20:34

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.