Python系统调用
使用这个命令时,我只得到了一个叫OUTPUT的文件(实际上我还有很多其他的--include标志),所以这个命令的效果是正常的:
os.system("rsync --rsh=ssh -arvuP --include='OUTPUT' --exclude='*' user@host:there/ ./here")
在这种情况下,--include和--exclude标志被忽略了:
subprocess.call("rsync --rsh=ssh -arvuP --include='OUTPUT' --exclude='*' user@host:there/ ./here".split())
我在做什么错了呢?非常感谢!
补充说明:抱歉,我是在OS X Leopard上操作的,我得到了所有的文件...
2 个回答
1
如果我没记错的话,Python确实有一个叫做rsync的模块,为什么不直接用这个呢?这样可以让你的应用程序更容易管理。
3
试试用 subprocess.call
并设置 shell=True
,这样会更接近于 os.system 的效果:
subprocess.call("...", shell=True)