Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

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.

pscp.exe -pw yourpassword you@somesite.org:/packages/package.zip .\

The path to /packages/package.zip should be whatever the path to the public web files are on the server. So, for example, on some old apache server, it might be:

pscp.exe -pw yourpassword you@somesite.org:/users/httpd/vhosts/default/packages/package.zip .\

Use pscp, which comes with PuTTY:

pscp user@host:/path/to/file.7z .
7z e file.7z

If you set this up with SSH keys, pscp won't have to ask you for a password.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top