mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-24 05:41:43 +02:00
Added edgeapps package, cleaned up redundancies
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module github.com/edgebox-iot/sysctl/internal/utils
|
||||
|
||||
go 1.15
|
||||
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Exec : Runs a terminal Command, catches and logs errors, returns the result.
|
||||
func Exec(command string, args []string) string {
|
||||
cmd := exec.Command(command, args...)
|
||||
var out bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Println(fmt.Sprint(err) + ": " + stderr.String())
|
||||
}
|
||||
log.Println("Result: " + out.String())
|
||||
|
||||
return out.String()
|
||||
}
|
||||
Reference in New Issue
Block a user