diff options
| author | Jeff Carr <[email protected]> | 2024-12-10 01:48:02 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-10 01:48:02 -0600 |
| commit | 8d692299b0229fe94ba99c26f79e609154c5388a (patch) | |
| tree | 8b790af8bb3e7a3545331d8f2f6d197170c1ce6a /cmd.go | |
| parent | 99eded53985df3d7926486b32edaf530346b85e4 (diff) | |
RunEcho()
Diffstat (limited to 'cmd.go')
| -rw-r--r-- | cmd.go | 40 |
1 files changed, 17 insertions, 23 deletions
@@ -2,7 +2,7 @@ package shell import ( "errors" - "fmt" + "os" "time" "github.com/go-cmd/cmd" @@ -139,6 +139,21 @@ func RunRealtime(args []string) cmd.Status { return PathRunRealtime("", args) } +func RunEcho(cmd []string) cmd.Status { + result := RunQuiet(cmd) + pwd, _ := os.Getwd() + log.Warn("shell.RunEcho() cmd:", cmd, pwd) + log.Warn("shell.RunEcho() Exit:", result.Exit) + log.Warn("shell.RunEcho() Error:", result.Error) + for _, line := range result.Stdout { + log.Warn("STDOUT:", line) + } + for _, line := range result.Stderr { + log.Warn("STDERR:", line) + } + return result +} + // echos twice a second if anything sends to STDOUT or STDERR // not great, but it's really just for watching things run in real time anyway // TODO: fix \r handling for things like git-clone so the terminal doesn't @@ -210,29 +225,8 @@ func PathRunRealtime(pwd string, args []string) cmd.Status { // Block waiting for command to exit, be stopped, or be killed finalStatus := <-statusChan + log.Info("shell.Run() notsure finalStatus", finalStatus.Cmd) return findCmd.Status() - return finalStatus -} - -func blah(cmd []string) { - r := Run(cmd) - log.Info("cmd =", r.Cmd) - log.Info("complete =", r.Complete) - log.Info("exit =", r.Exit) - log.Info("err =", r.Error) - log.Info("len(stdout+stderr) =", len(r.Stdout)) -} - -// run these to see confirm the sytem behaves as expected -func RunTest() { - blah([]string{"ping", "-c", "3", "localhost"}) - blah([]string{"exit", "0"}) - blah([]string{"exit", "-1"}) - blah([]string{"true"}) - blah([]string{"false"}) - blah([]string{"grep", "root", "/etc/", "/proc/cmdline", "/usr/bin/chmod"}) - blah([]string{"grep", "root", "/proc/cmdline"}) - fmt.Sprint("blahdone") } // this is stuff from a long time ago that there must be a replacement for |
