curl
CURL is simply awesome because of the following reasons...
CURL is an easy to use command line tool to send and receive files, and it supports almost all major protocols(DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP) in use
Can be used inside your shell scripts with ease
Supports features like pause and resume of downloads
It has around 120 command line options for various tasks
It runs on all major operating systems(More than 40+ Operating systems)
Supports cookies, forms and SSL
Both curl command line tool and libcurl library are open source, so they can be used in any of your programs
It supports configuration files
Multiple upload with a single command
Progress bar, rate limiting, and download time details
ipv6 support
Download a Single File
The following command will get the content of the URL and display it in the STDOUT (i.e on your terminal).
$ curl http://www.centos.org
To store the output in a file, you an redirect it as shown below. This will also display some additional download statistics.
$ curl http://www.centos.org > centos-org.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 27329 0 27329 0 0 104k 0 --:--:-- --:--:-- --:--:-- 167k
Fetch Multiple Files at a time
We can download multiple files in a single shot by specifying the URLs on the command line.
Syntax:
Syntax:
$ curl -O URL1 -O URL2
Pass HTTP Authentication in cURL
Sometime, websites will require a username and password to view the content ( can be done with .htaccess file ). With the help of -u option, we can pass those credentials from cURL to the web server as shown below.
$ curl -u username:password URL
Upload Files to FTP Server
Curl can also be used to upload files to the FTP server with -T option.
$ curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
Send Mail using SMTP Protocol
cURL can also be used to send mail using the SMTP protocol. You should specify the from-address, to-address, and the mailserver ip-address as shown below.
$ curl --mail-from blah@test.com --mail-rcpt foo@test.com smtp://mailserver.com
Comments
Post a Comment