diff options
Diffstat (limited to 'client/go/util/run_cmd.go')
-rw-r--r-- | client/go/util/run_cmd.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/go/util/run_cmd.go b/client/go/util/run_cmd.go new file mode 100644 index 00000000000..fe6ae5d297f --- /dev/null +++ b/client/go/util/run_cmd.go @@ -0,0 +1,24 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Author: arnej + +package util + +import ( + "bytes" + "os" + "os/exec" + "strings" + + "github.com/vespa-engine/vespa/client/go/trace" +) + +// this is basically shell backticks: +func GetOutputFromProgram(program string, args ...string) (string, error) { + cmd := exec.Command(program, args...) + var out bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = os.Stderr + trace.Debug("running command:", program, strings.Join(args, " ")) + err := cmd.Run() + return out.String(), err +} |