Before answering the questions below, you should know that exec.Command will not do shell glob expansion since it does not invoke commands via a shell. If you want to do that you can either invoke via a shell or do the globbing yourself with filepath.Glob[1].
1. You can capture the combined output or stderr using the exec.Cmd CombinedOutput method or Stderr field respectively. 2. exec.Command does not know anything about recursive copy of directories, it just invokes commands. 3. This depends on exactly what it is that you are trying to achieve. [1]https://golang.org/pkg/path/filepath/#Glob On Mon, 2017-01-16 at 13:35 -0800, Deepak Jain wrote: > util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json", > artifact. > dir)) > > func ExecuteCommandWithOuput(cmd *exec.Cmd) { > output, err := cmd.Output() > if err != nil { > log.Print("Error executing ", cmd.Args, err) > } > fmt.Print(string(output)) > } > > > Output > > 2017/01/16 13:26:35 Error executing [cp -r ./*.json myartifact] exit > status > 1 > > > Questions > 1. How do i get details of complete error message on failure of cp > command > ? I did have err != nill and Print err > 2. Does exec.Command not support copy of files and recursive copy of > directories ? > 3. Any suggestions how i implement copy of files and recursive copy > of > directories ? > > I have just started adopting Go and hence a new comer with Go. > Regards, > Deepak > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.