我正在使用 rsync 命令创建一个新目录来保存图像命令是 "rsync -ave --rsync-path='mkdir -p "+ path + "&& rsync' "+ filePath + "ubuntu@"+ LocalhostIp + ":"+ path
但是在运行我的代码时这个命令会给我错误错误是
错误:
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]
编辑
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
}
我该如何解决这个错误?
最佳答案
您需要删除 -e
选项,因为这是将以下工作 (--rsync-path=...
) 替换为 ssh命令。例如,
$ rsync -ave --x_x /tmp/a abc@localhost:/tmp/y
rsync: Failed to exec --x_x: No such file or directory (2)
只需使用-av
。
关于ubuntu - 如何解决rsync error : error in IPC code (code 14) at pipe. c(85) [sender=3.1.2]的报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53369009/