python脚本中的scp命令不工作
我有一个问题好几天了。在我的 Raspberry Pi 上,我转到终端执行以下命令:
scp [email protected]:/home/path/to/file/test.py /home/pi/update/test.py
它工作正常,并且无需密码(因为 ssh-keys)即可将文件从服务器复制到我的本地计算机。
但是:我必须在 python 脚本中执行完全相同的操作:
import os
cmd = 'scp [email protected]:/home/path/to/file/test.py /home/pi/update/test.py'
os.system(cmd)
这不起作用并给出错误
ssh: Could not resolve hostname subdomain.server.com: Temporary failure in name resolution
为什么我会收到此消息,特别是如何解决它?请问有人给个建议吗?我不明白...
I have a problem for several days. On my Raspberry Pi I go to the terminal for executing the following command:
scp [email protected]:/home/path/to/file/test.py /home/pi/update/test.py
It works fine and copies the file from the server without password (because of ssh-keys) to my local machine.
BUT: I have to do exactly the same within a python script:
import os
cmd = 'scp [email protected]:/home/path/to/file/test.py /home/pi/update/test.py'
os.system(cmd)
This doesn't work giving an error
ssh: Could not resolve hostname subdomain.server.com: Temporary failure in name resolution
Why do I get this message and especially how can I solve it? Does anyone give an advice, please? I don't understand it ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论