Linux curl is a file transfer tool that works under the command line using URL Rules. It supports file uploads and downloads, so it is a comprehensive transfer tool, but traditionally, the URL is used as a download Tool.
a, Curl Command parameters, There are many I have not used, do not know whether the translation is right, if the wrong place, please correct Me.
-a/--append when uploading a file, attach to target file-a/--user-agent <string> set user agent to send to server-anyauth can use "any" authentication method-b/-- Cookie <name=string/file> cookie string or file read Location-basic uses HTTP basic authentication-b/--use-ascii using Ascii/text Transfer-c/--cookie-jar < File> write the cookie to this file after the operation is Finished-c/--continue-at <offset> breakpoint Continuation-d/--data <data> HTTP Post Data Transfer--data-ascii <data> post data in Ascii--data-binary <data> post data in binary mode--negotiate using HTTP authentication--digest to use digital authentication--disable-eprt Prohibit use of EPRT or lprt--disable-epsv disable the use of Epsv-d/--dump-header <file> write header information to the File--egd-file <file> Set EGD socket path for random data (SSL)--tcp-nodelay use tcp_nodelay option-e/--referer source Url-e/--cert <cert[:p asswd]> Client certificate file and password (ssl)--cert-type <type> certificate file type (der/pem/eng) (ssl)--key <key> private key file name ( Ssl)--key-type <type> private key file type (der/pem/eng) (ssl)--pass <pass> private Key Password (ssl)--engine <eng> encryption engine use (ssl). "--engine list" for List--cacert <file> CA certificate (SSL)--capath <directory> CA directory (made using c_rehash) to verify Peer against (ssl)--ciphers <list> SSL password--compressed requirements Return is a compressed situation (using deflate or gzip)-- Connect-timeout <seconds> Set maximum request time--create-dirs establish a directory hierarchy of local directories--crlf upload is to convert LF into crlf-f/--fail HTTP error not displayed when connection Fails--ftp-create-dirs if remote directory does not exist, create remote Directory--ftp-method [multicwd/nocwd/singlecwd] control the use of cwd--ftp-pasv Ignore this IP address when using PASV/EPSV instead of PORT--FTP-SKIP-PASV-IP to use PASV--ftp-ssl attempt to use SSL/TLS for FTP data transfer--ftp-ssl-reqd requires SSL/TLS for FTP data transfer-f/--form <name=content> Simulate HTTP form submission data-form-string <name=string> simulate HTTP form submission data-g/--globoff disable URL sequence and range use {} and []-g/--get to send data in a get way-h/-- Help-h/--heAder <line> Custom header information is passed to the server--ignore-content-length the length of the HTTP header information that is Ignored-i/--include output includes protocol header Information-i/--head Show only document information read from File-j/--junk-session-cookies ignore session cookie-interface <interface> Specify network interface/address USAGE-KRB4 < level > Enable with the specified security level krb4-j/--junk-session-cookies read file into ignore session Cookie--interface <interface> use specified network Interface/address--krb4 < level> using a specified security level of Krb4-k/--insecure allows the specified configuration file to be read-l/--list-only list the file name under the FTP directory without using the certificate to the SSL site-k/--config - Limit-rate <rate> Set Transfer speed--local-port<num> Force local port number-m/--max-time <seconds> set Maximum transfer time--max-redirs <num> set the maximum number of directories to Read--max-filesize <bytes> set the maximum amount of files downloaded-m/--manual display full MANUAL-N/--NETRC read the user name and password from the NETRC file-- Netrc-optional use the. netrc or URL to overwrite-n--ntlm use HTTP NTLM authentication-n/- -no-buffer Disable Buffered Output-o/--output writes the output to the File-o/--remote-name writes the output to the file, retains the file name of the remote files-p/--proxytunnel uses the HTTP proxy-- Proxy-anyauth Select either proxy authentication method--proxy-basic use Basic authentication on the Proxy--proxy-digest uses the digital authentication on the proxy--proxy-ntlm uses NTLM authentication on the Proxy-p/--ftp-port <address> uses the port address, Instead of using pasv-q/--quote <cmd> file transfer, Send command to Server-r/--range <range> retrieve byte range from http/1.1 or FTP server--range-file Read (SSL) random file-r/--remote-time When a file is generated locally, keep remote file Time--retry <num> The number of retries when there is a problem with the transmission-- Retry-delay <seconds> When there is a problem with the transmission, set the retry interval time--retry-max-time <seconds> The maximum retry time-s/--silent mute mode when there is a problem with the Transmission. Do not output anything-s/--show-error display ERROR--SOCKS4 two, commonly used Curl instance
1, crawl the page content into a file
View Copy print?
- [email protected] mytest]# Curl-o home.html http://blog.51yip.com
2, with-o (uppercase), The following URL to specific to a file, or not catch it down. We can also use the regular to grab things.
View Copy print?
- [[email protected] mytest]# Curl-o http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg
- [[email protected] mytest]# Curl-o http://blog.51yip.com/wp-content/uploads/2010/[0-9][0-9]/aaaaa.jpg
3, simulate form information, simulate login, save cookie information
View Copy print?
- [email protected] mytest]# curl-c/cookie_c.txt-f log=aaaa-f pwd=****** http://blog.51yip.com/wp-login.php
4, simulating form information, simulating login, saving header information
View Copy print?
- [email protected] mytest]# curl-d/cookie_d.txt-f log=aaaa-f pwd=****** http://blog.51yip.com/wp-login.php
The cookie generated by-c (lowercase) is not the same as the cookie In-d.
5, Use cookie File
View Copy print?
- [email protected] mytest]# curl-b./cookie_c.txt http://blog.51yip.com/wp-admin
6, The breakpoint continues to pass,-c (uppercase)
View Copy print?
- [[email protected] mytest]# curl-c-o http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg
7, Transfer the data, it is best to use the login page test, because you pass the value of the past, curl back to grasp the data, you can see that you pass the value has no success
View Copy print?
- [email protected] mytest]# curl-d log=aaaa http://blog.51yip.com/wp-login.php
8, Show the fetch error, the following example, it is very clear that.
View Copy print?
- [[email protected] mytest]# curl-f http://blog.51yip.com/asdf
- Curl: () The requested URL returned error:404
- [[email protected] mytest]# Curl http://blog.51yip.com/asdf
-
- 。。。。。。。。。。。。
9, Forged Source address, Some website will judge, request source Address.
View Copy print?
- [[email protected] mytest]# curl-e http://localhost http://blog.51yip.com/wp-login.php
10, when we often use curl to engage in People's things, people will put your IP to shield off, this time, we can use the agent
View Copy print?
- [email protected] mytest]# curl-x 24.10.28.84:32779-o home.html http://blog.51yip.com
11, than the larger stuff that we can download in sections
View Copy print?
- [email protected] mytest]# curl-r 0-100-o img.part1 http://blog.51yip.com/wp-
- Content/uploads/2010/09/compare_varnish.jpg
- % total% Received% xferd Average speed Time Time current
- Dload Upload Total spent
- 101 101 0 0 0--:--:----:---:----:--:--0
- [email protected] mytest]# curl-r 100-200-o img.part2 http://blog.51yip.com/wp-
- Content/uploads/2010/09/compare_varnish.jpg
- % total% Received% xferd Average speed Time Time current
- Dload Upload Total spent
- 100 101 100 101 0 0 57 0 0:00:01 0:00:01--:--:--0
- [[email protected] mytest]# curl-r 200--o img.part3 http://blog.51yip.com/wp-
- Content/uploads/2010/09/compare_varnish.jpg
- % total% Received% xferd Average speed Time Time current
- Dload Upload Total spent
- 104k 104k 0 0 52793 0 0:00:02 0:00:02--:--:--88961
- [[email protected] mytest]# ls |grep part | Xargs Du-sh
- 4.0K One.part1
- 112K Three.part3
- 4.0K Two.part2
When you use them, catimg.part* >img.jpg
12, download Progress information is not displayed
View Copy print?
- [[email protected] mytest]# curl-s-o aaa.jpg http://blog.51yip.com/wp-content/uploads/2010/09/compare_ Varnish.jpg
13, Show Download progress bar
View Copy print?
- [[email protected] mytest]# curl-#-o http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg
- ######################################################################## 100%
14. Download files via FTP
View Copy print?
- [[email protected] ~]$ curl-u username: password-o http://blog.51yip.com/demo/curtain/bbstudy_files/style.css
- % total% Received% xferd Average speed Time Time current
- Dload Upload Total spent
- 101 1934 101 1934 0 0 3184 0--:--:----:--:----:--:--7136
Or in the following way
View Copy print?
- [[email protected] ~]$ Curl-o ftp://user name: password @ip:port/demo/curtain/bbstudy_files/style.css
15, Upload via FTP
View Copy print?
- [[email protected] ~]$ curl-t test.sql ftp://user name: password @ip:port/demo/curtain/bbstudy_files/
A detailed description of the Linux Curl command, as well as examples