summaryrefslogtreecommitdiff
path: root/unix.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-10 19:44:38 -0600
committerJeff Carr <[email protected]>2024-01-10 19:44:38 -0600
commit0d23f7271a7ebb4dc251cbf23df32c2ab738d9b6 (patch)
tree2f019653adba3acd61a855d417a6b8f6ea6a0634 /unix.go
parent348f01091ca0c0f1a5d1ed19729e9b3da7f84280 (diff)
rescan()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'unix.go')
-rw-r--r--unix.go37
1 files changed, 37 insertions, 0 deletions
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
+}