我有一些使用rsync
模块执行subprocess
的自动备份脚本。
在指定ssh身份文件的新要求之前一切正常。
根据rsync
手册,ssh标识应作为带引号的字符串传递:
-e "ssh -i /home/username/.ssh/identity"
但这将无法在subprocess
中运行:
subprocess.Popen(['rsync', '-avz', '-e "ssh -i /home/username/.ssh/identity"', '~/Downloads', 'root@remote_server:/lvm/archive/backup'])
<subprocess.Popen object at 0x7fd111939710>
rsync: Failed to exec ssh -i /home/username/.ssh/identity: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.0]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(226) [sender=3.1.0]
有什么想法吗?
由于
答案 0 :(得分:1)
subprocess.Popen(['rsync', '-avz', '-e', 'ssh -i /home/username/.ssh/identity', '~/Downloads', 'root@remove_server:/lvm/archive/backup'])