cmd := exec.Command("bash", "-c", "rm -rf *")
cmd.Dir = "/root/media/"
err := cmd.Run()
if err != nil {
fmt.Println(err)
fmt.Fprintf(w, "'rm -rf *' command failed.")
}
"err": exit with status 1 I think I am not writing exec.Command correctly, but I cannot fix this.
The command that is going to be executed in bash
should be enclosed with double quote (or single quote), e.g.
cmd := exec.Command("bash", "-c", `"rm -rf *"`)