Curl使用详解(六)

31 TELNET远程登录

The curl telnet support is basic and very easy to use. Curl passes all data passed to it on stdin to the remote server. Connect to a remote telnet server using a command line similar to: curl只支持基本的、非常简单的telnert操作。curl将标准输入的内容全部发送到远程服务器。连接到远程telnet服务器使用以下命令:

curl telnet://remote.server.com

And enter the data to pass to the server on stdin. The result will be sent to stdout or to the file you specify with -o. 然后将在标准输入中输入的数据传送至服务器。执行结果将被发送至标准输出,如果你希望将执行结果保存至文件,请使用参数-o。
You might want the -N/–no-buffer option to switch off the buffered output for slow connections or similar. 针对低速网络连接等情况,你也许通过参数-N/–no-buffer来关闭输出缓存。
Pass options to the telnet protocol negotiation, by using the -t option. To tell the server we use a vt100 terminal, try something like: 通过使用参数-t,可以向telnet传送协议允许的选项。如果我们想告知服务器将使用vt100终端 来进行连接,应输入如下命令:
curl -tTTYPE=vt100 telnet://remote.server.com
Other interesting options for it -t include:对于-t, 其他有趣的选项还包括:

   - XDISPLOC=<X display> Sets the X display location.
   - NEW_ENV=<var,val> Sets an environment variable.

NOTE: The telnet protocol does not specify any way to login with a specified user and password so curl can’t do that automatically. To do that, you need to track when the login prompt is received and send the username and password accordingly. 注意:telnet协议没有指定任何以指定用户和密码登录的方式,所以curl不能自动完成。要做到这一点,还需要跟踪何时收到登录提示并相应地发送用户名和密码。

32 PERSISTENT CONNECTIONS持久连接

Specifying multiple files on a single command line will make curl transfer all of them, one after the other in the specified order. 在一个命令中进行多个文件将会让curl按命令中指定的文件顺序一个接一个的传输所有的文件。
libcurl will attempt to use persistent connections for the transfers so that the second transfer to the same host can use the same connection that was already initiated and was left open in the previous transfer. This greatly decreases connection time for all but the first transfer and it makes a far better use of the network. libcurl将会尝试使用持久连接来传输全部文件,这样第二个文件也可以使用已经完成初始化并仍旧对前一次传输开放的同一连接来进行传输。这样将大幅度减少传输全部文件所需的连接次数,对于网络的合理使用也大有好处。
Note that curl cannot use persistent connections for transfers that are used in subsequence curl invokes. Try to stuff as many URLs as possible on the same command line if they are using the same host, as that’ll make the transfers faster. If you use an HTTP proxy for file transfers, practically all transfers will be persistent. 注意:curl本身对于传输并不使用持久连接,传输的持久连接只是curl在随后发起的库调用。尽可能多的在一个命令行中使用大量的URL向同一服务器传输文件,这会里整体的传输速度变得更快。实际 上,如果你使用HTTP代理来传输文件,你就会发现所有的传输使用的都是持久连接。

33 MULTIPLE TRANSFERS WITH A SINGLE COMMAND LINE单条命令行下的多路传输

As is mentioned above, you can download multiple files with one command line by simply adding more URLs. If you want those to get saved to a local file instead of just printed to stdout, you need to add one save option for each URL you specify. Note that this also goes for the -O option (but not –remote-name-all). 根据上面内容提到的方法,通过简单的添加多个URL,你可以在一个命令中下载多个文件。如果你希望将这些文件存储到本地文件中而不是打印输出至标准输出的话,你需要针对每个URL指定选项-O(而不需要使用–remote-name-all)
For example: get two files and use -O for the first and a custom file name for the second: 例如:下载二个文件,对第一文件使用-O,并自定义第二文件的文件名:

curl -O http://url.com/file.txt ftp://ftp.com/moo.exe -o moo.jpg

You can also upload multiple files in a similar fashion: 你可以使用相似的模式来上传多个文件:

curl -T local1 ftp://ftp.com/moo.exe -T local2 ftp://ftp.com/moo2.txt

34 IPv6

curl will connect to a server with IPv6 when a host lookup returns an IPv6 address and fall back to IPv4 if the connection fails. The –ipv4 and –ipv6 options can specify which address to use when both are available. IPv6 addresses can also be specified directly in URLs using the syntax: 当使用IPv4进行连接失败,并且服务器返回的是一个IPv6地址的情况下,curl将使用IPv6连接服务器。 选项–ipv4和–ipv6,可以在这二种地址都可用时指定使用哪种地址进行连接。IPv6地址还可以在URL中直接进行指定,具体方法如下:

http://[2001:1890:1112:1::20]/overview.html

When this style is used, the -g option must be given to stop curl from interpreting the square brackets as special globbing characters. Link local and site local addresses including a scope identifier, such as fe80::1234%1, may also be used, but the scope portion must be numeric or match an existing network interface on Linux and the percent character must be URL escaped. The previous example in an SFTP URL might look like: 使用这种格式时,必须同时指定选项-g,否则curl将认为[]是全局字符,而导入停止执行命令。 本地链接和本地站点地址包含一个标识符范围,如fe80::1234%1,这些标识符也有可能被用到,但是其中一部分必须是数字或者匹配在linux系统中已经存在的网络适配器,并且百分号必须被URL转义。上一个例子中内容转换成SFTP URL将会是下面的样子:

sftp://[fe80::1234%251]/

IPv6 addresses provided other than in URLs (e.g. to the –proxy, –interface or –ftp-port options) should not be URL encoded. IPv6地址在URL以外提供的选项不应该编码为URL,如:–proxy, –interface、–ftp-port。

35 METALINK账号

Curl supports Metalink (both version 3 and 4 (RFC 5854) are supported), a way to list multiple URIs and hashes for a file. Curl will make use of the mirrors listed within for failover if there are errors (such as the file or server not being available). It will also verify the hash of the file after the download completes. The Metalink file itself is downloaded and processed in memory and not stored in the local file system. curl支持Metalink,包括version 3 和 4 (RFC 5854),一种可以列出多个URI资源并针对文件可以进行hash的方法。如果出现无法获取文件或者无法连接服务器等错误,curl将会把备用资源列表中资源做为镜像来使用。并且在下载完成之后,还会对文件进行hash校验。Metalink文件会在内存中完成上述的下载和处理工作,并不会将它们存储的本地文件系统中。
Example to use a remote Metalink file: 例如使用远程Metalink文件:

curl --metalink http://www.example.com/example.metalink

To use a Metalink file in the local file system, use FILE protocol (file://):

curl --metalink file://example.metalink

Please note that if FILE protocol is disabled, there is no way to use a local Metalink file at the time of this writing. Also note that if –metalink and –include are used together, –include will be ignored. This is because including headers in the response will break Metalink parser and if the headers are included in the file described in Metalink file, hash check will fail.

36 MAILING LISTS邮件列表

For your convenience, we have several open mailing lists to discuss curl, its development and things relevant to this. Get all info at https://curl.haxx.se/mail/. Some of the lists available are: 为了方便讨论curl、软件的开发以及与其相关的事宜,我们为您开放一了些邮件列表。你可以在如下网址获得相关信息https://curl.haxx.se/mail/。其中一些邮件列表为:
curl-users
Users of the command line tool. How to use it, what doesn’t work, new features, related tools, questions, news, installations, compilations,running, porting etc. 针对命令行工具的用户。讨论的内容包括:如何使用curl,软件工作异常,新功能,相关工具,使用中遇到的问题,新闻,安装,编译,运行,端口等等。
curl-library
Developers using or developing libcurl. Bugs, extensions, improvements. 开发者使用或者开发libcurl,包括:Bugs,扩展,改进。
curl-announce
Low-traffic. Only receives announcements of new public versions. At worst, that makes something like one or two mails per month, but usually only one mail every second month. 邮件量很少。只接受公布新版本的通知。最多每月发送一至二封邮件,通常情况下,每二个月只发送一封邮件。
curl-and-php
Using the curl functions in PHP. Everything curl with a PHP angle. Or PHP with a curl angle. 用curl的函数应用于PHP, 包括所有curl与PHP相关的内容。
curl-and-python
Python hackers using curl with or without the python binding pycurl. 用于反馈Python骇客在绑定pycurl的情况下,无论是否在python环境下使用curl遇到的问题。
Please direct curl questions, feature requests and trouble reports to one of these mailing lists instead of mailing any individual. 请直接反馈curl的问题,功能性要求和故障报告到以上邮件列表中,而不要发送私人邮件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值