Re: [go-nuts] Help needed - os.exec

2020-04-05 Thread Ian Lance Taylor
On Sun, Apr 5, 2020 at 3:36 PM R Srinivasan wrote: > > I cannot figure the error in the following. > package main > > import ( > "io" > "os" > "os/exec" > "strings" > ) > > func Run(args []string) { > lf, _ := os.Create("lf.log") > defer lf.Close() > cmd := exec.Command(args[0], strings.Join(args[

Re: [go-nuts] Help needed - os.exec

2020-04-05 Thread burak serdar
On Sun, Apr 5, 2020 at 4:36 PM R Srinivasan wrote: > > I cannot figure the error in the following. > cmd := exec.Command(args[0], strings.Join(args[1:], " ")) Do not join the args. You're passing one arg, "build ./", instead of two args "build" "./" to exec. Instead: cmd := exec.Command(args[0],

[go-nuts] Help needed - os.exec

2020-04-05 Thread R Srinivasan
I cannot figure the error in the following. package main import ( "io" "os" "os/exec" "strings" ) func Run(args []string) { lf, _ := os.Create("lf.log") defer lf.Close() cmd := exec.Command(args[0], strings.Join(args[1:], " ")) stderr, _ := cmd.StderrPipe() cmd.Start() io.Copy(lf, stderr) cmd.Wai