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?