curl 打印其 pid 然后在后台运行

Dr.*_*ini 3 download curl files

我正在通过一个简单的curl请求体验新事物。

该命令是 curl 的简单调用,例如:

curl http://example.com/endpoint/?arg1=val1&arg2=val2

这个调用应该返回一个 500+ MB 的 XML 文件(准备好后,我会把-O它保存到一个文件中),但没有什么奇怪的,真的。

奇怪的是 curl 只是打印它的 pid 并进入后台:

[1] 31562

过了一会儿,远程文件开始出现在控制台中,并且在后台,我无法使用Ctrl+C.

我从来没有经历过这样的事情。如果我尝试下载 1.9 GB 的文件:

curl -O https://download.microsoft.com/download/0/A/F/0AFB5316-3062-494A-AB78-7FB0D4461357/7601.17514.101119-1850_Update_Sp_Wave1-GRMSP1.1_DVD.iso

它工作正常!

任何的想法?

来自常规下载的标题:

curl -v -s https://download.microsoft.com/download/0/A/F/0AFB5316-3062-494A-AB78-7FB0D4461357/7601.17514.101119-1850_Update_Sp_Wave1-GRMSP1.1_DVD.iso 1> /dev/null
*   Trying 92.123.112.141:443...
* TCP_NODELAY set
* Connected to download.microsoft.com (92.123.112.141) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
... more HTTPS stuff ...
} [5 bytes data]
> GET /download/0/A/F/0AFB5316-3062-494A-AB78-7FB0D4461357/7601.17514.101119-1850_Update_Sp_Wave1-GRMSP1.1_DVD.iso HTTP/1.1
> Host: download.microsoft.com
> User-Agent: curl/7.65.3
> Accept: */*
> 
{ [5 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/octet-stream
< Accept-Ranges: bytes
< Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
< x-ms-blob-content-md5: mw6jWIuMir1+rZG9/mzj+A==
< Last-Modified: Sat, 13 Oct 2018 00:34:54 GMT
< ETag: "0x8D630A3B1CF6138"
< Content-Length: 2048196608
< Date: Mon, 10 Feb 2020 21:11:55 GMT
< Connection: keep-alive
< 
{ [16038 bytes data]
^C
Run Code Online (Sandbox Code Playgroud)

我的电话:

*   Trying 192.168.0.200:80...
* TCP_NODELAY set
* Connected to example.com port 80 (#0)
> GET /endpoint/?arg1=val1&arg2=val2 HTTP/1.1
> Host: example.com
> User-Agent: curl/7.65.3
> Accept: */*
> 
^C
Run Code Online (Sandbox Code Playgroud)

Kus*_*nda 8

该 URL 包含&,这意味着您的命令将启动

curl http://example.com/endpoint/?arg1=val1
Run Code Online (Sandbox Code Playgroud)

在后台,然后将 shell 变量arg2设置为 value val2,因为这就是 shell 解析该行时 URL 的下一位的含义。

在 URL 周围使用引号:

curl 'http://example.com/endpoint/?arg1=val1&arg2=val2'
Run Code Online (Sandbox Code Playgroud)