sys - add RunBufferedShellCmd
This commit is contained in:
parent
6aa0b46e03
commit
cd9e69a8dc
10
sys/sys.go
10
sys/sys.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user