How can you download a file/zip from the commandline using putty?

52,134

Solution 1

wget is of course an obvious solution, but I also suggest to have a look at cURL. From their website:

curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks.

Of course free and open source, and despite its huge list of supported protocols it's as simple to use as wget, so to use your example

curl -O http://somesite.org/packages/package.zip 

downloads package.zip to a local file with the same name

curl -o myname.zip http://somesite.org/packages/package.zip 

downloads package.zip as myname.zip

curl http://somesite.org/packages/package.zip > package.zip 

redirects curl's stdout to package.zip

EDIT - example corrected, with thanks to @PrabhakarKasi

Solution 2

win32 version of wget:

http://pages.interlog.com/~tcharron/wgetwin.html

Solution 3

Putty isn't really a download tool. Unless you want to download something via SCP/SFTP. So yes, wget is more helpful here.

Solution 4

I don't know putty, but certainly wget can do. If you are in Windows, you can get it by cygwin or just google a win32 version.

Share:
52,134
qodeninja
Author by

qodeninja

I write qode mostly for myself... out of curiosity for solving problems, understanding how things work or making (sometimes unnecessarily) complex systems to only simplify them later (once I discover alternative strategies). For whatever reason, I like torturing myself with Regular Expressions, SED, Bash and JavaScript (Node), but have found a growing (painful) love with Python. Having said that, I enjoy scripting languages a lot more than compiled languages, and I've coded in almost all of the major modern ones except Ruby. I'm a secret Turing Machine/Computer Grammars/Regular Expressions nerd, and have written my own mini compilers and toy languages. I'm constantly writing command dispatchers that I later write scripting languages for; it's an addiction. There's plenty room for me to grow and learn still; and I appreciate the wisdom of grey beards and lady wizards even if I don't always follow their sage advice. FOSS is hella cool; cool projects are cool. Find me online if you have ideas. I'm a really bad programmer but I'll write a line or two for the betterization of the peoples. Edit: I recently discoved that VI is really just SED with wings. Still not using VI. Nano or bust.

Updated on April 24, 2020

Comments

  • qodeninja
    qodeninja about 4 years

    I'm trying to write a batch script (CMD @ Windows XP Pro) that will automatically download and unzip packages with the help of 7zip and putty/psftp

    If I have a URL to a package to download http://somesite.org/packages/package.zip how do I download it on command line using putty?

    Also if you have a better way to do this that would be helpful too.

  • Stefan Kendall
    Stefan Kendall over 14 years
    +1 for curl. Those of us that use linux/unix often are prone to use what we know, but that doesn't always mean it's the best solution for windows environments.
  • fvu
    fvu over 14 years
    @Stefan cURL exists under Linux/Unix too, in fact I started using it under HP/UX to solve some hard-to-shellscript ftp exchange problems. Afterwards I discovered that it also existed for Windows :-)