From be72ffec435c04550eab78a7b37f0d4981fdf1f9 Mon Sep 17 00:00:00 2001 From: amorozov Date: Fri, 21 Jun 2024 15:31:41 +0300 Subject: [PATCH] feature: added process utils --- .../process/process_execution/process_execution.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pkg/os/process/process_execution/process_execution.go diff --git a/pkg/os/process/process_execution/process_execution.go b/pkg/os/process/process_execution/process_execution.go new file mode 100644 index 0000000..68fb90a --- /dev/null +++ b/pkg/os/process/process_execution/process_execution.go @@ -0,0 +1,14 @@ +package process_execution + +import "os/exec" + +func ExecuteAndGetOutput(command string, args ...string) (string, error) { + outputBytes, err := exec.Command(command, args...).CombinedOutput() + outputString := "" + + if outputBytes != nil && len(outputBytes) > 0 { + outputString = string(outputBytes) + } + + return outputString, err +}