我已经设置了一个计算引擎,我可以在命令提示符中使用ssh命令,比如
gcloud compute ssh test-instance@cloud-engine-noapi --zone us-central1-f --command "rm -f test.txt"
并成功删除服务器中的test.txt。
但是,当我在Python中调用这些函数时。
subprocess.call(['gcloud', 'compute', '--project', 'test-project','ssh', temp_instance, '--zone', zone, '--command', '"cd /home"'], shell=True)
subprocess.call(['gcloud', 'compute', '--project', 'test-project','ssh', temp_instance, '--zone', zone, '--command', '"ls -l"'], shell=True)
subprocess.call(['gcloud', 'compute', '--project', 'test-project','ssh', temp_instance, '--zone', zone, '--command', '"rm -f /home/test.txt"'], shell=True)
回报总是像
bash: /command : No such file or directory
为了命令
ls
bash: /command : command not found
我有什么事要先做吗?