Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-18 Thread ๏̯͡๏
Thanks for time in responding. Appreciate. On Wed, Jan 18, 2017 at 1:46 PM, roger peppe wrote: > > > On 17 January 2017 at 19:14, Deepak Jain wrote: > >> I fixed the error by invoking Copy command with abs source path. >> >> srcPath, _ := >> e := util.Copy(srcPath, dst) >> >> If i could modify

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-18 Thread roger peppe
On 17 January 2017 at 19:14, Deepak Jain wrote: > I fixed the error by invoking Copy command with abs source path. > > srcPath, _ := > e := util.Copy(srcPath, dst) > > If i could modify into a single line > > util.Copy(filepath.Abs(filepath.Dir(src)), dst) > Throws error as filepath.Abs(filepath.

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-18 Thread roger peppe
On 17 January 2017 at 18:50, Deepak Jain wrote: > Thanks for pointing to https://github.com/juju/ > utils/blob/master/fs/copy.go > > > I was testing Copy function that recursively copies directories. I am able > to copy first level of files and it creates directories. It fails to copy > the conte

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Matt Harden
In Go, don't try to combine those actions into a single line. Also you shouldn't ignore the error from filepath.Abs. On Tue, Jan 17, 2017 at 11:14 AM Deepak Jain wrote: > I fixed the error by invoking Copy command with abs source path. > > srcPath, _ := > e := util.Copy(srcPath, dst) > > If i co

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Deepak Jain
I fixed the error by invoking Copy command with abs source path. srcPath, _ := e := util.Copy(srcPath, dst) If i could modify into a single line util.Copy(filepath.Abs(filepath.Dir(src)), dst) Throws error as filepath.Abs(filepath.Dir(src)) returns a tuple. In scala i can use _1, _2 to acces

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Deepak Jain
Thanks for pointing to https://github.com/juju/utils/blob/master/fs/copy.go I was testing Copy function that recursively copies directories. I am able to copy first level of files and it creates directories. It fails to copy the contents within those directories. func Copy(src, dst string) er

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread roger peppe
You don't really need to use the external cp command: https://play.golang.org/p/F1YHzQL4UN On 16 January 2017 at 21:35, Deepak Jain wrote: > util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json", > artifact.dir)) > > func ExecuteCommandWithOuput(cmd *exec.Cmd) { > output, err := cmd.O

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Konstantin Khomoutov
On Mon, 16 Jan 2017 13:35:07 -0800 (PST) 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) > } >

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Deepak Jain
Thanks for Stderr. I would like to do a recursive copy of a directory (similar to cp -r ), directory can contain files (binaries or text files) and directories. I now see exit status 1: cp: ./*.json: No such file or directory Code: //ExecuteCommandWithOuput will execute cmd passed as argumen

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Dan Kortschak
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

[go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Deepak Jain
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 -