繁体   English   中英

来自python的Rsync找不到路径

[英]Rsync from python can't find path

我尝试通过 Popen 和 subprocess.check_call 从 python 运行 rsync,得到了同样的错误:

subprocess.check_call(['rsync', '-au', '/opt/catflow/EpressCatalog/*', '/Users/pistacchio/dev/epress/catflow/portal/branches/noscript/frontend/static/repo/usr/2/catalogs/2/builds/ipad'])
rsync: link_stat "/opt/catflow/EpressCatalog/*" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
*** CalledProcessError: Command '['rsync', '-au', '/opt/catflow/EpressCatalog/*', '/Users/pistacchio/dev/epress/catflow/portal/branches/noscript/frontend/static/repo/usr/2/catalogs/2/builds/ipad']' returned non-zero exit status 23

似乎问题在于它找不到(或访问) /opt/catflow/EpressCatalog/* 它不仅存在,而且从命令行运行它会给出正确的结果。

有什么帮助吗?

subprocess模块自己处理参数的引用。 当一个参数条目中有空格时,默认情况下会引用它。

简化示例

['-input', 'eggs.txt', '-output', 'spam spam.txt']

在外壳上被称为

-input eggs.txt -output "spam spam.txt"

安全说明:切勿使用shell=True 它打开了外壳注入攻击的风险。 有关详细信息,请参阅官方文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM