1 Download single file
$
curl http://www.centos.org > filename.html
2 save cuRL output to file
$
curl -o mygettext.html http://www.abcd.org/software/gettext/manual/gettext.html
-o
<filename>= save o/p to a filename provided
$
curl -O http://www.abcd.org/software/gettext/manual/gettext.html
-O
= save o/p to default name provided here "gettext.html"
Resume Downloads
curl
-C - -O http://www.gnu.org/software/gettext/manual/gettext.html
############### 21.1%
continue download ==> curl -C - -O URL
To Limit data transfer rate
curl
--limit-rate 1000B -O http://www.gnu.org/software/gettext/manual/gettext.html
3 Downlaod in a single shot by specifying the
URLs on the command line.
Syntax:
$
curl -O URL1 -O URL2
Follow HTTP Location Headers with -L
option(follow redirection)
$
curl -L http://www.google.com
Download a file only if it is modified
before/after the given time
$ curl -z 29-Nov-13
http://www.example.com/yy.html
The above command will download the
yy.html only if it is modified later than the given date and time
$ curl -z -21-Dec-11
http://www.example.com/yy.html
The above command will download the
yy.html, if it is modified before than the given date and time.
Download
File from FTP
$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php
The above command will download the xss.php file from the ftp server and
save it in the local directory.$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/Here, the given URL refers to a directory. So cURL will list all the files and directories under the given 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
The above command will upload the
file named myfile.txt to the FTP server. You can also upload multiple files at
a same time using the range operations.
$
curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com
Optionally we can use “.” to get the
input from STDIN and transfer to the remote.
$
curl -u ftpuser:ftppass -T - ftp://ftp.testserver.com/myfile_1.txt
The above command will get the input
from the user from Standard Input and save the contents in the ftp server under
the name ‘myfile_1.txt’.
You can provide one ‘-T’ for each
URL and the pair specifies what to upload where.
Use
Proxy to Download a File
We can specify cURL to use proxy to do the specific operation using -x
option. We need to specify the host and port of the proxy.$ curl -x proxysever.test.com:3128 http://google.co.in
curl -kv -o /dev/null https://d25wtkfk22ou2e.cloudfront.net/img/1451890642907b3558a5fd9bb9a3a923983ceea618/640/400?fixedratio=1
No comments:
Post a Comment