The problem is expanding shell meta characters like *, ? and ~ is a property of the _shell_, as Dan mentioned above. You are executing a command directly so the shell is not involved and cannot expand *.json into a list of files ending with .json.
A cheap solution to this might be something like util.ExecuteCommandWithOuput(exec.Command("sh", "-c", cp", "-r", *.json", artifact.dir)) Which will pass your command to sh to run, and thus expand (untested, but should be close). On Tuesday, 17 January 2017 18:02:17 UTC+11, Deepak Jain wrote: > > I appended pwd command output to source directory, i still get same error. > > pwd := util.ExecuteCommandWithOuput(exec.Command("pwd")) > fmt.Println("pwd", pwd) > util.ExecuteCommandWithOuput(exec.Command("cp", "-r", pwd+"/./*.json", > artifact.dir)) > > > Output: > > Cmd:[cp -r /Users/userId/sd101 /./*.json myartifact] > exit status 1: cp: /Users/userId/sd101 > /./*.json: No such file or directory > > I believed that above change should have worked. > > Any suggestions ? > > > > Appreciate your time. > > On Monday, January 16, 2017 at 7:35:57 PM UTC-8, 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.