How to solve the error of the rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.2]

被刻印的时光 ゝ 提交于 2019-12-24 18:51:14

问题


I'm using a command of rsync for making a new directory to save the images the command is "rsync -ave --rsync-path='mkdir -p " + path + " && rsync' " + filePath + " ubuntu@" + LocalhostIp + ":" + path but while running my code this command will gives me the error the error is

Error:

exit status 14: rsync: Failed to exec --rsync-path=mkdir: No such file or directory (2)

rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.2]

rsync: connection unexpectedly closed (0 bytes received so far) [sender]

rsync error: error in IPC code (code 14) at io.c(235) [sender=3.1.2]

Edit

func CopyUploadedFileToAppServers(filePath, path string) {
   ExecuteCommand("rsync -ave --rsync-path='mkdir -p " + path + " && rsync' " + filePath + " ubuntu@" + LocalhostIp + ":" + path)
}

func ExecuteCommand(command string) error{
 cmd := exec.Command("sh", "-c",command)
 var out bytes.Buffer
 var stderr bytes.Buffer
 cmd.Stdout = &out
 cmd.Stderr = &stderr

 err := cmd.Run()

 if err != nil {
    fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
    return err
 }
 fmt.Println("Result: " + out.String())
 return nil
}

How can I solve this error?


回答1:


You need to remove the -e option, as this is taking the following work (--rsync-path=...) as the replacement for the ssh command. For example,

$ rsync -ave --x_x  /tmp/a abc@localhost:/tmp/y
rsync: Failed to exec --x_x: No such file or directory (2)

Just use -av.



来源:https://stackoverflow.com/questions/53369009/how-to-solve-the-error-of-the-rsync-error-error-in-ipc-code-code-14-at-pipe-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!