Wednesday, April 14, 2010

cURL commandline utility

A command line tool for getting or sending files using URL syntax.

Since cURL uses libcurl, it supports a range of common Internet protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, LDAPS, DICT, TELNET, FILE, IMAP. POP3, SMTP and RTSP.

The name of the project is a play on 'Client for URLs', originally with URL spelled in uppercase to make it obvious it deals with URLs. The fact it can also be pronounced 'see URL' also helped; it works as an abbreviation for "Client URL Request Library" or the recursive version: "Curl URL Request Library". Distributed under the MIT License, cURL is free software.

Basic use of cURL involves simply typing curl at the command line, followed by the URL of the output to retrieve.

To retrieve the example.com homepage, type:

curl http://www.google.com.au

cURL defaults to displaying the output it retrieves to the standard output specified on the system (usually the terminal window). So running the command above would display the source-code of the google.com.au homepage.

cURL can write the output it retrieves to a file with the -o flag, thus:

curl -o example.html www.example.com

A practical example is the cURL for testing the twitter api like posting the tweet (status) as below:
curl -u username:password http://api.twitter.com/1/direct_messages.xml

Quickest way to download files:
eg: curl -o j2ee-6.pdf http://java.sun.com/javaee/6/docs/tutorial/doc/JavaEETutorial.pdf
PS: this is indeed a good doc ;)

No comments:

Post a Comment