update RunCmd

This commit is contained in:
Matthew R. Kasun 2022-02-08 23:18:58 -05:00
parent e88d34ac96
commit 747baf1bba
2 changed files with 12 additions and 2 deletions

View file

@ -103,7 +103,7 @@ netclient_args="daemon"`
}
func FreebsdDaemon(command string) {
out, err := ncutils.RunCmd("service netclient "+command, true)
out, err := ncutils.RunCmdFormatted("service netclient "+command, true)
ncutils.Log("output from RunCmd " + out)
ncutils.Log("error from RunCmd " + err.Error())
}

View file

@ -2,6 +2,7 @@ package ncutils
import (
"context"
"fmt"
"log"
"os/exec"
"strings"
@ -11,7 +12,16 @@ import (
// RunCmdFormatted - run a command formatted for freebsd
func RunCmdFormatted(command string, printerr bool) (string, error) {
return "", nil
args := strings.Fields(command)
cmd := exec.Command(args[0], args[1:]...)
cmd.Wait()
out, err := cmd.CombinedOutput()
if err != nil && printerr {
Log(fmt.Sprintf("error running command: %s", command))
Log(strings.TrimSuffix(string(out), "\n"))
}
return string(out), err
}
// GetEmbedded - if files required for freebsd, put here