将gsutil输出传递到文件 [英] Pipe gsutil output to file

查看:201
本文介绍了将gsutil输出传递到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候StackOverflow,

Greetings StackOverflow,

我正在Windows上的一个小项目中,该项目需要读取GSUTIL复制功能的输出.问题是,复制功能的输出似乎无法通过标准输出"工作.此外,GSUTIL的行为也不一致:管道输出不适用于复制功能,但可以使用列表功能.

I'm working on a small project on Windows which needs to read the output of GSUTIL's copy function. Problem is, the output of the copy function doesn't seem to work via the Standard Output. Also, the behavior of GSUTIL is inconsistent: piping output doesn't work with the copy function but using the list function is does work.

当我在命令提示符下使用以下命令时,输出将显示在命令提示符下,但未重定向到文本文件.此命令无法正常工作:

When I use the following command in my command prompt the output is displayed in the command prompt but not redirected to the text file. This command doesn't work right:

C:\gsutil> python gsutil cp "file://C:/test_files/*" gs://gs_teststore/ > gsutil_cp.txt

另一方面,当我使用列表函数(ls)时,输出确实可以通过标准输出,并且可以按我希望的方式工作:

On the otherhand when I use the list function (ls) the output does work through the standard output and works at I hoped:

C:\gsutil> python gsutil ls gs://gs_teststore/ > gsutil_ls.txt

是否可以从GSUTIL的复制功能捕获输出?

Is there a way to capture the output from the copy function of the GSUTIL?

推荐答案

您可以使用-L选项生成所有已复制文件的清单文件.来自文档:

You can use the -L option to generate a manifest file of all files that were copied. From the documentation:

-L< file>输出清单日志文件,其中包含有关复制的每个项目的详细信息.此清单包含以下内容 每个项目的信息:

-L <file> Outputs a manifest log file with detailed information about each item that was copied. This manifest contains the following information for each item:

  • 源路径.
  • 目的地路径.
  • 源大小.
  • 已传输字节.
  • MD5哈希.
  • UTC日期和时间传输以ISO 8601格式开始.
  • UTC日期和时间传输已以ISO 8601格式完成.
  • 上传ID(如果已执行可恢复的上传).
  • 尝试上传,成功或失败的最终结果.
  • 故障详细信息,如果有的话.
  • Source path.
  • Destination path.
  • Source size.
  • Bytes transferred.
  • MD5 hash.
  • UTC date and time transfer was started in ISO 8601 format.
  • UTC date and time transfer was completed in ISO 8601 format.
  • Upload id, if a resumable upload was performed.
  • Final result of the attempted upload, success or failure.
  • Failure details, if any.

一个具体示例:

$ echo "hey" | gsutil cp -L manifest.txt - gs://mybucket/hey.txt
Copying from <STDIN> [Content-Type=application/octet-stream]...

$ cat manifest.txt 
Source,Destination,Start,End,Md5,UploadId,Source Size,Bytes Transferred,Result,Description
file://-,gs://mybucket/hey.txt,2013-05-29T21:29:31.847715Z,2013-05-29T21:29:32.115624Z,081ecc5e6dd6ba0d150fc4bc0e62ec50,,,0,OK,

这篇关于将gsutil输出传递到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆