using curl in os x

I decided to experiment with the curl command today after becoming extremely frustrated trying to download files on a Mac in our China office. Now, we get a lot of lag whenever we have to remotely control a mac across the (other) pond, so I am always looking for ways to use the command line to remote control macs in China. It’s still laggy, but not as much and at least I don’t have to watch it be so.

All I needed to do was download the server admin tools on one of the iMacs over there so I could do a basic setup on the brand new mac mini server the company just purchased. After about 15 minutes of watching a “frozen” login window, I decided to try this through SSH and use a command that until recently I did not know much about, curl.

cURL = client Uniform Resource Locator. Essentially it’s a text-only client for reading web pages and downloading/uploading files, but it seems that the power of curl lies in the sheer amount of ways you can do these simple tasks. I found some great online resources for curl, one of them being http://curl.haxx.se/

It turns out that curl is quite easy to use to download files with this basic command:

curl -C - -O <url>

Keep in mind that <url> has to be the full path to the downloadable file or else curl won’t work to download the file. Also keep in mind that’s a capital O, not a zero. the ‘-C -‘ option specifies to resume a previous failed (or canceled) download and to tell curl to automatically find out where/how to do so, but don’t worry it will work even if this is the first attempt. The ‘-O’ tells curl to write output to a file of the same name as the downloaded file and save this log in the same directory. And finally, if you want to see curl’s progress use the ‘-v’ option.

To get the proper URL for downloading a file, visit the webpage that has the file you want, and instead of left-clicking on the link to the file, right-click the link instead and choose to Copy Link. Then just paste this link in place of the <url> above.


About this entry