Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Dan Kortschak
exec.Command does not invoke a shell, the `>' you use in bash is a shell function (https://www.gnu.org/software/bash/manual/bash.html#Redi rections). Note that the example for CombinedOutput invokes "sh" as the command with "-c", "ls... (https://golang.org/pkg/os/exec/#example_Cmd_ CombinedOutput).

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Caleb Spare
ls is a bash builtin. You can probably invoke the ls command with /bin/ls. But also, passing ">" as an argument to exec.Command doesn't do what you want. > is a redirection for a shell and exec.Command is not a shell. I'm not sure what you're trying to accomplish, but here are two things you coul

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread andrey mirtchovski
">" is a special character interpreted by your shell. On Sun, Nov 12, 2017 at 8:35 PM, wrote: > package main > > import( > "fmt" > "os/exec" > ) > > func main () > cmd := exec.Command("ls", ">", "/dev/null") > output, err := cmd.CombinedOutput() > if err != nil { > fmt.Println(fmt.Sprint(err) +

[go-nuts] Simple exec.Command() program

2017-11-12 Thread bucarr
package main import( "fmt" "os/exec" ) func main () cmd := exec.Command("ls", ">", "/dev/null") output, err := cmd.CombinedOutput() if err != nil { fmt.Println(fmt.Sprint(err) + ": " + string(output)) } When I run this go program I get: exit status: 1: ls: >:No such file or directory /dev/null