From cd9e69a8dc3210552c2789e84d23b6099975cea3 Mon Sep 17 00:00:00 2001 From: mahdi Date: Sat, 25 Nov 2023 13:30:49 +0100 Subject: [PATCH] sys - add RunBufferedShellCmd --- sys/sys.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/sys.go b/sys/sys.go index 2d7f0ab..24bae46 100644 --- a/sys/sys.go +++ b/sys/sys.go @@ -45,6 +45,16 @@ func RunShellCmd(call string) int { return ManageStatusCmd(cmd, cmd.Run()) } +func RunBufferedShellCmd(call string, out *bytes.Buffer) int { + cmd := exec.Command("sh", "-c", call) + rs1, err := cmd.CombinedOutput() + if err != nil { + fmt.Println("Error: ", err) + } + out.Write(rs1) + return ManageStatusCmd(cmd, err) +} + func ManageStatusCmd(cmd *exec.Cmd, err error) int { if err == nil { return 0