如何仅通过 FTP“获取”部分文件

Jax*_*Jax 8 ftp

我正在开发一种工具来获取一些隐藏在远程系统上一个非常大的文件中的数据。复制整个文件是不切实际的,我需要的所有数据都存在于文件的前 1000 个字节左右。我知道我可以开始一个 get 并用 ^C 取消它以获得部分文件,但是这将很难(如果不是不可能的话)以任何一致性进行自动化。

我想告诉我的 ftp 客户端只抓取远程文件的 x 字节,并在有它们后立即退出。我发现了一些可以部分下载的 Windows 客户端,但我在 ftp 手册页中没有找到任何内容,而且在线文档很少。

我发现这个 HowTo:http : //cdsarc.u-strasbg.fr/doc/ftp.htx建议以下语法:

ftp> get bigfile.dat:0-5000 bigfile.nxt
Run Code Online (Sandbox Code Playgroud)

我不清楚这是否应该在客户端或服务器中实现,但在任何一种情况下,它似乎都不适用于我的环境。(标准 linux ftp 客户端连接到在 z/OS 上运行的 FTP 服务器)

即使在 Windows 上的 linux 标准 ftp 客户端和 filezilla 服务器之间尝试时,我的尝试也会以下列方式失败

ftp> get green.gif:0-10c
local: green.gif:0-10c remote: green.gif:0-10c
227 Entering Passive Mode (9,42,91,226,4,105)
550 File not found
Run Code Online (Sandbox Code Playgroud)

所以 :0-10c 被解释为文件名的一部分。失败。有什么想法吗?

Mik*_*eyB 10

使用卷曲。从手册页:

   -r/--range <range>
          (HTTP/FTP/FILE)  Retrieve  a byte range (i.e a partial document)
          from a HTTP/1.1, FTP server or a local FILE. Ranges can be spec-
          ified in a number of ways.

          0-499     specifies the first 500 bytes

          500-999   specifies the second 500 bytes

          -500      specifies the last 500 bytes

          9500-     specifies the bytes from offset 9500 and forward

          0-0,-1    specifies the first and last byte only(*)(H)

          500-700,600-799
                    specifies 300 bytes from offset 500(H)
Run Code Online (Sandbox Code Playgroud)

但是,请注意,服务器必须支持 SIZE 扩展才能使其工作。


Mat*_*ons 7

我想你想为此使用 curl

从手册页:

   -r/--range <range>
          (HTTP/FTP/FILE)  Retrieve  a byte range (i.e a partial document)
          from a HTTP/1.1, FTP server or a local FILE. Ranges can be spec?
          ified in a number of ways.

          0-499     specifies the first 500 bytes

          500-999   specifies the second 500 bytes

          -500      specifies the last 500 bytes

          9500-     specifies the bytes from offset 9500 and forward
Run Code Online (Sandbox Code Playgroud)