Curl command line downloads

If you need a command line download on Linux there are several options.  Wget for a simple download is a very good option but I prefer curl as I have had more success when dealing with logins, cookies and uploads than with wget.

Plus if you need to go further and integrate something with python or php the curl libraries are awesome.

Simple download:

$ curl -o myfile.iso ""

With login:

$ curl -o myfile.iso -u user:password ""
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
 Dload  Upload   Total   Spent    Left  Speed
 100 3509M  100 3509M    0     0  6204k      0  0:09:39  0:09:39 --:--:-- 7106k

** Note sometimes to get the correct download string you will need to login into the site with your browser and copy the download location of the link.  Or in some cases actually initiate the download with the browser and then copy the link from the browser download window.

If you are after a more permanent web or scripted solution you can use curl to login and save the cookie.  Then subsequently download the file using the generated cookie.  This requires more experimentation with your particular site.

Login and save a cookie:

$ curl -c cookie.txt -u user:password

List files:

$ curl -b cookie.txt -u user:password

Upload a file:

$ curl -b cookie.txt --upload-file test.rrosso


If you are behind corporate firewalls you might still be able to use curl.
Behind socks5 proxy:

$ curl --socks5 -U rrosso:pwd -c cookie2.txt -u site-user:pwd (login and save a cookie)
$ curl --socks5 -U rrosso:pwd -b cookie2.txt -u site-user:pwd (list files using saved cookie)
$ curl --socks5 -U rrosso:pwd -b cookie2.txt --upload-file test.rrosso

Behind squid proxy:

$ curl -x -U rrosso:pwd -o ARP08110610926072.txt_171317.RECVD -u site-user:pwd

$ curl -x -U rrosso:pwd -c cookie2.txt -u site-user:pwd
Virtual user site-user logged in.

$ curl -x -U rrosso:pwd -b cookie2.txt -u site-user:pwd
total 38

$ curl -x -U rrosso:pwd -b cookie2.txt -u site-user:pwd --upload-file rrosso-test


Bio Info for Riaan