Use of curl in Shell

Source: Internet
Author: User

Curl is a URL access tool that can be used to construct HTTP request packets and parse the HTTP response returned by the server. It also supports cookie features and can be used to complete basic web browser functions. Curl also supports https, FTP, ftps, telnet, LDAP, and other protocols. This article only explores its powerful HTTP functions.

General Syntax:

Curl [Option] [url...]

When processing a URL, it supports shell-type name extension, such

The options are as follows:

Without any parameters, curl returns data from the specified URL and prints the data on the screen.

-O out: the specified curl is returned and saved as an out file. The content ranges from HTML/jpg to various mime-type files.

-O save the downloaded file by name on the server

-R/-- range from-to download data in the specified range

-C resume the upload when saving the file

-A/-- User-Agent <UA> specifies the user agent sending the request, such as curl-a my-agent/1.0.0 www.apple.com.

-X ip: Port indicates the HTTP proxy used, for example, curl-x 192.168.1.1: 8080 www.apple.com.

-D head.txt saves the header returned by the server as a file, and the cookie of the header can also be saved as curl-D header.txt www.apple.com

-C <File> Save the cookie file of the server

-B/-- cookie <name = data>: Submit the cookie to the server. If no value = is set, the name is regarded as the file name curl-B cookie.txt www.apple.com.

-E url: set the value of the reference Header

-T localfile: put a file to the server, such as curl-T 1.mp3 www.apple.com/upload.php.

-D <key = value> to the server post form data such as curl-d "Order = 111 & COUNT = 2" http://www.apple.com/buy

-F <key = value> post the form curl-F "website@index.html to the server; type = text/html" url.com

If you want to get form data from a local file, add @ such as curl-d @ data. xml http://www.apple.com before the file name

Use curl-D-http://www.apple.com if you want to get from standard input

-E Cert. pem: Specifies the local certificate

-H

-I: Construct a head request

-X/-- Request Method the User-Defined HTTP Request Method Name, such as curl-x get www.baidu.com

-- Compressed receives returned data in compression mode

-- Connect-Timeout <S>: Set the timeout value.

-V detailed output, including the request and Response Header

-- Retry num

-- Retry timeo specifies the number and interval of retries.

-- TCP-nodelay enable the tcp_nodelay option and do not confirm with the sequence.

Environment variable: http_proxy [Protocol: //]

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.