mirror of
https://github.com/NotAShelf/batmon.git
synced 2024-11-26 23:26:48 +00:00
22 lines
431 B
Go
22 lines
431 B
Go
|
package exec
|
||
|
|
||
|
import (
|
||
|
"os/exec"
|
||
|
|
||
|
"gomon/internal/logger"
|
||
|
)
|
||
|
|
||
|
// execute a command with args and returns its output
|
||
|
// this will be used primarily for executing external commands if configured
|
||
|
// or executing bash commands verbatim
|
||
|
func ExecCommand(name string, arg ...string) error {
|
||
|
cmd := exec.Command(name, arg...)
|
||
|
err := cmd.Run()
|
||
|
if err != nil {
|
||
|
logger.Error("Failed to execute command")
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|