tags:

views:

171

answers:

6

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.

Thanks!

+1  A: 

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.

Codism
A: 

pscp.exe -pw yourpassword [email protected]:/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 [email protected]:/users/httpd/vhosts/default/packages/package.zip .\

Clay Fowler
+1  A: 

win32 version of wget:

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

Stefan Kendall
+1  A: 

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.

Warren Young
+1  A: 

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

Joey
+1  A: 

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 http://somesite.org/packages/package.zip
fvu
+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.
Stefan Kendall
@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 :-)
fvu