2016-01-01 32 views
1

我需要在Windows 7 x64(使用cwRsync 5.5.0)从Python 2.7应用程序运行rsync。从窗口中的python子进程运行rsync

一切正常,从命令行:在ENV 集CWRSYNCHOME到cwrsync二进制文件,并运行以下命令

rsync.exe "/cygdrive/e/test" [email protected]: 

但试图运行相同的命令蟒子时:

process = subprocess.Popen(['rsync.exe', '/cygdrive/e/test', '[email protected]:'], 
          stdout=subprocess.PIPE, 
          stderr=subprocess.PIPE, 
          shell=True, 
          env={'CWRSYNCHOME': './bin'}) 

stdout, stderr = process.communicate() 
print 'STDOUT:{}\nSTDERR:{}'.format(stdout, stderr) 

我得到stderr中出现以下错误:

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

Here是冗长的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集外壳=假,并通过命令作为单条线(未CMD和args) - 错误STIL重复。

我在做什么错了?

回答

1

得到它的工作,需要的rsync在cygwin下的shell中拼命地跑:

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

它的工作(有例子中没有SSH athorization以上)。

相关问题