1

I'm trying to download a file, https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe or https://www.7-zip.org/a/7z1806-x64.exe, without using curl or wget; rather, I want to download the file by using telnet as follows.

(echo 'GET /~sgtatham/putty/latest/w64/putty.exe'; echo ""; sleep 1; ) | telnet the.earth.li 80 > s.exe

This does not work; when I use cat the file contents are as follows.

HTTP/1.1 302 Found
Date: Sun, 17 Feb 2019 18:40:22 GMT
Server: Apache
Location: https://the.earth.li/~sgtatham/putty/0.70/w64/putty.exe
Content-Length: 301
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://the.earth.li/~sgtatham/putty/0.70/w64/putty.exe">here</a>.</p>
<hr>
<address>Apache Server at the.earth.li Port 80</address>
</body></html>
6
  • 1
    In the reply from the server, you see that the document has moved to a new address. It also tells you what the new address is. Commented Feb 17, 2019 at 18:53
  • after following the new address, you’ll also have to remove the http header from the response Commented Feb 17, 2019 at 18:56
  • 2
    You are going to have to be very good at hand-writing TLS handshakes to do that with telnet from an HTTPS URL. I think you're out of luck. Commented Feb 17, 2019 at 18:57
  • forget what I said, the command "(echo 'GET /~sgtatham/putty/0.70/w64/putty.exe'; echo ""; sleep 1; ) | telnet the.earth.li 80 > s.exe " seems to just work without even having to remove headers Commented Feb 17, 2019 at 19:02
  • 1
    If you have openssl installed, openssl s_client -host the.earth.li -port 443 -crlf will do the job. Otherwise you may want to put a copy somewhere HTTP-accessible. Commented Feb 17, 2019 at 19:14

1 Answer 1

1

From the reply you can see that the "document has moved" to "https://the.earth.li/~sgtatham/putty/0.70/w64/putty.exe", so you should just change the link in your command (change "latest" to "0.70").
Your browser does this automatically. The command should be:
(echo 'GET /~sgtatham/putty/0.70/w64/putty.exe'; echo ""; sleep 1; ) | telnet the.earth.li 80 > s.exe

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.