为什么这个gcloud计算副本文件会产生错误消息?

Ros*_*son 14 google-compute-engine gcloud

当我执行命令

gcloud compute copy-files"C:\ Users\fName lName\Desktop\testtext.txt"instancename:test.txt --zone europe-west1-a

我收到错误:"All sources must be local files when the destination is remote.".

任何人都可以帮我弄清楚出了什么问题吗?

小智 17

要复制您指定的文件testtext.txt,您需要位于该文件所在的路径中,并在复制而不是路径时指定其名称.

示例:从您的命令行可以假设您在此路径中:

C:\ Users\fName lName\Desktop \

您的命令应如下:

gcloud compute copy-files --zone europe-west1-b testtext.txt instancename:/PATH_where_you_want_the_file
Run Code Online (Sandbox Code Playgroud)


Jef*_*han 10

谢谢你问这个!这似乎是我们现在正在追踪的gcloud中的一个错误.问题是gcloud compute copy-files将冒号解释C:\Users\fNam...为远程路径的一部分.正如George的回答所建议的,解决方法是避免包含冒号字符的本地路径.


det*_*acy 7

例如,要将远程目录复制到本地主机,请运行:

   gcloud compute copy-files \
      my-instance:~/remote-dir \
      ~/local-dir \
      --zone us-central1-a
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,"my-instance"中的"/ remote-dir"被复制到"/ local-dir"目录中.相反,可以将本地计算机中的文件复制到虚拟机:

gcloud compute copy-files \
    ~/my-local-file-1 \
    ~/my-local-file-2 \
    my-instance:~/remote-destination \
    --zone us-central1-a
Run Code Online (Sandbox Code Playgroud)

这是一个真实的实例:

将远程文件目录复制到本地主机,运行:

gcloud compute copy-files \
      instance-4:~/ \
      ~/Desktop/project/scripts/step/folder/* \
      --zone asia-east1-a \
      --project 911911911911911 \
Run Code Online (Sandbox Code Playgroud)

可以将本地计算机中的所有文件复制到虚拟机:

gcloud compute copy-files \
    ~/Desktop/project/scripts/step/folder/* \
    instance-3:~/ \
    --zone asia-east1-a \
    --project 911911911911911 \
Run Code Online (Sandbox Code Playgroud)


小智 5

而不是"C:\ Users\fName lName\Desktop\testtext.txt"
使用"\ Users\fName lName\Desktop\testtext.txt".这对我有用