在windows下从python子进程运行rsync

2024-09-29 20:16:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要在Windows7x64中从Python2.7应用程序运行rsync(使用cwrsync5.5.0)。在

通过命令行一切正常: 将env中的cwrsyncome设置为cwrsync二进制文件并运行以下命令

rsync.exe "/cygdrive/e/test" test1@192.168.1.14:

尝试与python子进程运行相同的命令:

^{pr2}$

我在stderr中得到以下错误:

rsync: pipe: Operation not permitted (1)
rsync error: error in IPC code (code 14) at pipe.c(59) [sender=3.1.2]

下面是详细的rsync标准输出:

FILE_STRUCT_LEN=16, EXTRA_LEN=4
cmd=<NULL> machine=192.168.1.14 user=test1 path=.
cmd[0]=ssh cmd[1]=-l cmd[2]=test1 cmd[3]=192.168.1.14 cmd[4]=rsync cmd[5]=--server cmd[6]=-vvvvve.LsfxC cmd[7]=. cmd[8]=. 
opening connection using: ssh -l test1 192.168.1.14 rsync --server -vvvvve.LsfxC . .  (9 args)
[sender] _exit_cleanup(code=14, file=pipe.c, line=59): entered
[sender] _exit_cleanup(code=14, file=pipe.c, line=59): about to call exit(14)

Tryed set shell=False,并以单行形式传递命令(而不是命令和参数)-错误stil重复出现。在

我做错什么了?在


Tags: 命令cmdlenserver错误exitcodeerror
1条回答
网友
1楼 · 发布于 2024-09-29 20:16:03

要使其正常工作,rsync需要在cygwin的shell下运行:

process = subprocess.Popen(['sh.exe', '-c',
                            'rsync /cygdrive/e/test test1@192.168.1.14:'],
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE,
                           stdin=subprocess.PIPE,
                           env={'CWRSYNCHOME': '/bin/',
                                'PATH': '/bin/'})

它正在工作(上面的示例中没有ssh athoritation)。在

相关问题 更多 >

    热门问题