From 0d23f7271a7ebb4dc251cbf23df32c2ab738d9b6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 10 Jan 2024 19:44:38 -0600 Subject: rescan() Signed-off-by: Jeff Carr --- unix.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'unix.go') diff --git a/unix.go b/unix.go index cbf6b28..7c9f8db 100644 --- a/unix.go +++ b/unix.go @@ -57,3 +57,40 @@ func listFiles(directory string) []string { return files } + +func runCmd(path string, cmdline string) (bool, string) { + parts := strings.Split(cmdline, " ") + if len(parts) == 0 { + log.Warn("command line was empty") + return false, "" + } + if parts[0] == "" { + log.Warn("command line was empty") + return false, "" + } + thing := parts[0] + parts = parts[1:] + + log.Warn("path =", path, "thing =", thing, "cmdline =", parts) + return false, "" + // Create the command + cmd := exec.Command(thing, parts...) + + // Set the working directory + cmd.Dir = fullpath(path) + + // Execute the command + output, err := cmd.CombinedOutput() + if err != nil { + log.Error(err) + log.Warn("output was", output) + log.Warn("cmd exited with error", err) + return false, string(output) + } + + tmp := string(output) + tmp = strings.TrimSpace(tmp) + + // Print the output + return true, tmp +} -- cgit v1.2.3