diff options
| author | Jeff Carr <[email protected]> | 2024-01-10 19:44:38 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-10 19:44:38 -0600 |
| commit | 0d23f7271a7ebb4dc251cbf23df32c2ab738d9b6 (patch) | |
| tree | 2f019653adba3acd61a855d417a6b8f6ea6a0634 /unix.go | |
| parent | 348f01091ca0c0f1a5d1ed19729e9b3da7f84280 (diff) | |
rescan()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'unix.go')
| -rw-r--r-- | unix.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 +} |
