A Little Curl

curl is a command-line program supplied with OS X. Open Terminal.app (it is in your Applications -> Utilities folder) and type man curl. (man is the application that reads manuals and in this case you are instructing the manual reading program to read the manual for the curl program)

The man page gives a description of curl. If you can't understand the description, essentially curl deals with many types of urls. Universal Resource Locators. That's the line that starts with "http://" in your browser window, but there are other types of urls than just the http protocol. There is ftp, mailto, smb, https, etc. Thus curl is a little command line program with many options to deal with urls on the command line.

The man page is long and jam packed with features. If you use the down arrow, you can scroll to the "OPTIONS" section of the curl manual. This lists different things you can tell curl for how to deal with an url. But we only need one. You would have to scroll a long while to see what option -o is -- you can press spacebar to do down a page at a time. With all those options, curl can be really complicated, and versatile. What we really need is a way to save the information returned when curl requests an url.

 -o/--output <file>

This allows curl to write what it retrieves from a url into a file named <file>.

Read the description of the -o switch (these little command line options are often called "switches") and when you are done, either scroll around the manual and read other information if you like, or press q to quit the man program. You will be returned to a command line prompt.

Here's how to use it...

Back to your web browser (Safari, Internet Explorer or Firefox, etc.) If you have a link to a picture, a movie, or an audio file, hold the ctrl (or "control") key and click on the link. A menu should appear and in the menu there should be an option to copy the link to the clipboard (ex "Copy link" in Safari). Select the link copy feature and return to Terminal. Type:

curl -o ~/Desktop/filename.xxx <paste>

make sure there is a space between xxx and where you paste the link. You paste by holding the command button (the Apple key or the one with the cloverleaf pattern) and the letter 'v'. filename.xxx should be the name you want the file to end up. It's best if it's the real name of the file, but at least use the same extension (.mp3, .mov, .jpg).

Real Example - because it's not always this easy.

You can't always just copy the link so here's a real example.

http://www.apple.com/trailers/ I drill down to a page where the QuickTime movie is loading. Then I go to the View menu of my browser and choose View Source.

It takes a little poking around but I do find the "EMBED" command for a quicktime movie and there are two links there. One is the "SRC" and the other is the "HREF". HREF is the link -- and the page says "Click here to see the movie" -- so I want that link. http://images.apple.com/movies/fox/fantastic_four/f4-int_fte-invis_woman_480.mov -- I copy the link from the text, and return to Terminal.

Unfortunately Apple is smarter than I am and this didn't work. I'm going to continue the article when I figure it out.

Related Websites