feature: added 'ExecuteAndGetOutputC' to process_execution
parent
be72ffec43
commit
f8094df331
|
@ -3,7 +3,17 @@ package process_execution
|
||||||
import "os/exec"
|
import "os/exec"
|
||||||
|
|
||||||
func ExecuteAndGetOutput(command string, args ...string) (string, error) {
|
func ExecuteAndGetOutput(command string, args ...string) (string, error) {
|
||||||
outputBytes, err := exec.Command(command, args...).CombinedOutput()
|
return ExecuteAndGetOutputC(nil, command, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExecuteAndGetOutputC(cfg func(*exec.Cmd), command string, args ...string) (string, error) {
|
||||||
|
process := exec.Command(command, args...)
|
||||||
|
|
||||||
|
if cfg != nil {
|
||||||
|
cfg(process)
|
||||||
|
}
|
||||||
|
|
||||||
|
outputBytes, err := process.CombinedOutput()
|
||||||
outputString := ""
|
outputString := ""
|
||||||
|
|
||||||
if outputBytes != nil && len(outputBytes) > 0 {
|
if outputBytes != nil && len(outputBytes) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue