Launch rsync through subprocess python in windows



  • Python 2.7. of the annex under windows 7 x64, start rsync to a remote vehicle.

    rsync - cwRsync 5.5.0.

    Everything's working well from the console: I'm setting CWRSYNCHOME= around, pointing to the binary and cygwin libraries, after which I'm launching a team.

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

    But when I try to get out of the python:

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

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

    Receiving a stderr error.

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

    Removal of rsync to stdout with option --verbose

    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)

    I tried to put shell=False, hand over the whole team along with the parameters of the same line, the mistake remains.

    What can I do wrong?



  • To be used, we should have started rsync inside the cygwin shell'a, so...

    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/'})
    

    There is no such error (the example is that the authorisation of ssh has been omitted above).




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2