go-cmd / cmd

Non-blocking external commands in Go with streaming output
MIT License
918 stars 128 forks source link

special character '>' #102

Closed 2013kaa closed 3 months ago

2013kaa commented 7 months ago

Hello I have a command to build gradle like: ./gradlew build final dependencies > dep.txt

but when executed through cmd.NewCmdOptions it gives an error when building in the Gradle: Task '>' not found in root project 'xxxx'.

tell me how to solve the problem?there may be some kind of special character escaping >

daniel-nichter commented 7 months ago

> is output redirection, not part of the command. So use Options to set streaming or buffered output (and to combine STDOUT or STDERR or not). If you choose streaming output, you'd read Cmd.Stdout (and/or .Stderr) channels and write them to a file. If you choose buffered output, you'd copy Status.Stdout (and/or .Stderr) to file.