batmon/internal/exec/exec.go

22 lines
432 B
Go
Raw Permalink Normal View History

2024-01-11 19:51:07 +00:00
package exec
import (
"os/exec"
2024-01-11 20:38:08 +00:00
"batmon/internal/logger"
2024-01-11 19:51:07 +00:00
)
// 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
}