sys - add RunBufferedShellCmd

This commit is contained in:
Mahdi Abu Yasmine 2023-11-25 13:30:49 +01:00
parent 6aa0b46e03
commit cd9e69a8dc

View File

@ -45,6 +45,16 @@ func RunShellCmd(call string) int {
return ManageStatusCmd(cmd, cmd.Run()) 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 { func ManageStatusCmd(cmd *exec.Cmd, err error) int {
if err == nil { if err == nil {
return 0 return 0