繁体   English   中英

Curl将tar.gz文件下载为ASCII

[英]Curl Downloads tar.gz file as ASCII

我正在尝试从带有curl的github存储库中下载tar.gz文件,但显然是在下载纯ASCII,因此我无法解压缩或解压缩该文件(如file命令所示,请参见我的堆栈的第三行)跟踪以下)。

另外一个重要的细节是,它正在AWS CodeBuild实例中运行。 但是,我可以在我的Mac上使用curl很好地下载它,这是一个正确的tar.gz文件。

这是我正在运行的命令:

curl -Lk0s https://github.com/gohugoio/hugo/releases/download/v0.49/hugo_0.49_Linux-64bit.tar.gz -o /tmp/hugo.tar.gz

完整的堆栈跟踪为:

[Container] 2018/12/03 05:39:44 Running command curl -Lk0s https://github.com/gohugoio/hugo/releases/download/v0.49/hugo_0.49_Linux-64bit.tar.gz -o /tmp/hugo.tar.gz
[Container] 2018/12/03 05:39:45 Running command file /tmp/hugo.tar.gz
/tmp/hugo.tar.gz: ASCII text, with no line terminators ***[NB. This is the output of the file command]***
[Container] 2018/12/03 05:39:45 Running command tar xvf /tmp/hugo.tar.gz -C /tmp
tar: This does not look like a tar archive
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[Container] 2018/12/03 05:39:45 Command did not exit successfully tar xvf /tmp/hugo.tar.gz -C /tmp exit status 2
[Container] 2018/12/03 05:39:45 Phase complete: INSTALL Success: false
[Container] 2018/12/03 05:39:45 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: tar xvf /tmp/hugo.tar.gz -C /tmp. Reason: exit status 2

我在这里做错了什么?

-L为我工作:

curl -L https://github.com/gohugoio/hugo/releases/download/v0.49/hugo_0.49_Linux-64bit.tar.gz -o /tmp/hugo.tar.gz

我首先尝试了没有任何标志的尝试,然后下载了重定向页面。

添加了-L来跟随重定向,结果是格式正确,完整的.tar.gz文件,该文件可以完美解压缩。 结果是其中包含一些文件的文件夹:

$ ls -l
total 41704
-rw-r--r--  1 xxxxxxxxxxx  staff     11357 Sep 24 05:54 LICENSE
-rw-r--r--  1 xxxxxxxxxxx  staff      6414 Sep 24 05:54 README.md
-rwxr-xr-x  1 xxxxxxxxxxx  staff  21328256 Sep 24 06:03 hugo

更新:我起初没有尝试过您的一组参数(-Lk0s),假设它也不适合我。 但是我刚刚尝试过,它对我有用。 我得到的是与-L相同的.tar.gz,它可以准确解压缩。 请为下载的文本文件提供内容,并在此处显示至少其中一些内容。 以纯文本或html的形式发送回去可能是某种错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM