Re: [go-nuts] exec.Command() always returns error status of 1 when it was executed successfully

2020-02-17 Thread Robert Engels
It would exec.Command returns the result code of the process not whether it was able to be executed. > On Feb 17, 2020, at 7:51 PM, Dan Kortschak wrote: > > What do you see when you > > bash -c "lspci | grep -i vga | grep -i nvidia" > echo $? > > If you have no nvidia line or no vga line i

Re: [go-nuts] exec.Command() always returns error status of 1 when it was executed successfully

2020-02-17 Thread Dan Kortschak
What do you see when you bash -c "lspci | grep -i vga | grep -i nvidia" echo $? If you have no nvidia line or no vga line in lspci, this will output 1. On Mon, 2020-02-17 at 14:41 -0800, Dean Schulze wrote: > This command always sets the err to "exit status 1" even though it > executes correctl

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

Re: [go-nuts] exec.Command

2016-10-05 Thread Marvin Renich
* hadiesmail...@gmail.com [161005 05:46]: > hi > > in the second arg in function exec.Command(), what i must put it?? > > and any my question is : > > i want run a cmd command.for example : cls > > how can i run this method? The second argument is a variadic argument, so you can omit it; see