Get the latest Age of Conan news and views at Massively!

Monday man page: curl


Today's man page covers one of my favorite utilities: curl. No, it's not a haircare product -- it's one of the most flexible download tools in the kit bag, with the ability to handle almost any protocol that can be addressed via a URL (hence the name, short for "client for URLs"). If there's a server out there that's reachable via HTTP, HTTPS, FTP, SFTP, SCP, and lots of other alphabet soup, curl can talk to it.

curl http://www.tuaw.com/2007/03/05/monday-man-page-curl/ -- display the source of this very article in Terminal
curl ftp://ftp.panic.com -- list the contents of a remote FTP site, in this case one with a pretty good FTP client
curl -o ~/Desktop/curl-man.html http://curl.haxx.se/docs/manpage.html -- copy the curl manpage to your desktop; if you use capital -O, the local file mirrors the remote filename

curl has an excellent usage manual at its site, detailing examples of use and advanced techniques. While there are zillions of ways to use curl in site testing, analysis and uploading, my favorite way of using it is as a quick file downloader. Read on for the details.
curl
does an awesome job of quickly and cleanly downloading files, making it perfect for DIY software distribution schemes. In my case, I keep a web-shared folder of current installers and packages zipped up for delivery, and then trigger the downloads via ssh and curl, all behind the user's back:

curl http://myserver.example.com/Installer.mpkg.zip -o /tmp/install.zip
unzip -o install.zip
sudo installer -pkg /tmp/Installer.mpkg -target /


If you wanted to do something really cool, though, you could take advantage of curl's ability to compare file timestamps, and trigger a download only when the source file is updated -- great for a login script:
curl -z updater.zip http://server.example.com/updater.zip
thereby making sure that the client always has the latest file downloaded. So handy!

Hannes adds a comment below that he always uses the -C option to allow curl to resume interrupted file downloads, a trick that Safari hasn't mastered yet:

curl -C -O http://example.com/bigfile.zip

One last fun trick: using curl to do dictionary lookups...

curl dict://dict.org/d:macintosh
20 aspen.miranda.org dictd 1.9.15/rf on Linux 2.6.18-3-k7 <auth.mime> <7204009.9729.1173071849@aspen.miranda.org>
250 ok
150 2 definitions retrieved
151 "Macintosh" gcide "The Collaborative International Dictionary of English v.0.48"
Mac \Mac\ prop. n.
Shortened form of {Macintosh}, a brand name for a personal
computer; as, the latest Mac has great new features.
[PJC]
.
151 "Macintosh" gcide "The Collaborative International Dictionary of English v.0.48"
Macintosh \Mac"in*tosh\, n.
1. Same as {Mackintosh}.
[1913 Webster]

2. [Trademark.] (Computers) A brand of personal computer
featuring an integrated system in which the hardware and
system-operating software were designed by or under the
control of a single company, the Apple Computer
Corporation; among personal computers, distinguished from
the {IBM-compatible} or {Intel-based} series of computers.
[PJC]

Reader Comments (Page 1 of 1)

TUAW Features


Mac 101 ask-tuaw
Mac News
WWDC (250)
.Mac (57)
Accessories (635)
Airport (74)
Analysis / Opinion (1329)
Apple (1638)
Apple Corporate (556)
Apple Financial (187)
Apple History (45)
Apple Professional (54)
Apple TV (160)
Audio (446)
Bad Apple (118)
Beta Beat (149)
Blogging (84)
Bluetooth (16)
Bugs/Recalls (56)
Cult of Mac (869)
Deals (214)
Desktops (115)
Developer (252)
Education (98)
eMac (10)
Enterprise (138)
Features (397)
Freeware (381)
Gaming (361)
Graphic Design (31)
Hardware (1281)
Holidays (37)
Humor (576)
iBook (65)
iLife (234)
iMac (184)
Internet (325)
Internet Tools (1309)
iTS (967)
iTunes (796)
iWork (21)
Leopard (367)
Mac mini (112)
Mac Pro (53)
MacBook (202)
MacBook Air (79)
Macbook Pro (220)
MobileMe (16)
Multimedia (439)
Odds and ends (1437)
Open Source (277)
OS (910)
Peripherals (208)
Podcasting (182)
Podcasts (89)
Portables (197)
PowerBook (135)
PowerMac G5 (50)
Retail (579)
Retro Mac (48)
Rig of the Week (42)
Rumors (629)
Software (4304)
Software Update (406)
Steve Jobs (252)
Stocking Stuffers (50)
Surveys and Polls (97)
Switchers (112)
The Woz (34)
TUAW Business (236)
Universal Binary (281)
UNIX / BSD (61)
Video (902)
Weekend Review (82)
WIN Business (47)
Wireless (83)
Xserve (39)
iPhone/iPod News
iPhone (1490)
iPod Family (2024)
App Store (17)
SDK (14)
Mac Events
One More Thing (27)
Liveblog (1)
Other Events (226)
Macworld (489)
Mac Learning
AppleScript (2)
Ask TUAW (101)
Blogs (85)
Books (26)
Books and Blogs (62)
Cool tools (443)
Hacks (459)
How-tos (482)
Interviews (43)
Mods (185)
Productivity (586)
Reviews (107)
Security (153)
Terminal Tips (58)
Tips and tricks (563)
Troubleshooting (166)
TUAW Features
iPhone 101 (26)
TUAW Labs (3)
Blast From the Past (17)
TUAW Tips (141)
Flickr Find (34)
Found Footage (81)
Mac 101 (88)
TUAW Interview (31)
Widget Watch (198)
The Daily Best (1)
TUAW Faceoff (4)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Cory Bohon871
2Robert Palmer5743
3Steven Sande5523
4Scott McNulty360
5Mat Lu358
6Dave Caolo330
7Erica Sadun282
8Brett Terpstra210
9Mike Schramm182
10Michael Rose1334
11Christina Warren938
12Joshua Ellis44
13Lisa Hoover26
14Chris Ullrich12
15Jason Clarke11

Featured Galleries

Macworld 2008 Keynote
Macworld 2008 Build-up
Apple Vanity Plates
DiscPainter
Macworld Expo 2007 show floor
The Macworld Faithful in Line
iPhone First Look
AT&T 3G Coverage Map
MobileMe Guided Tour UI Changes

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Weblogs, Inc. Network

    Other Weblogs Inc. Network blogs you might be interested in: