RunBackgroundShell runs a shell command in the background It returns a function which will run the command and returns a string message result
(input string)
| 49 | // It returns a function which will run the command and returns a string |
| 50 | // message result |
| 51 | func RunBackgroundShell(input string) (func() string, error) { |
| 52 | args, err := shellquote.Split(input) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | if len(args) == 0 { |
| 57 | return nil, errors.New("No arguments") |
| 58 | } |
| 59 | inputCmd := args[0] |
| 60 | return func() string { |
| 61 | output, err := RunCommand(input) |
| 62 | |
| 63 | str := output |
| 64 | if err != nil { |
| 65 | str = fmt.Sprint(inputCmd, " exited with error: ", err, ": ", output) |
| 66 | } |
| 67 | return str |
| 68 | }, nil |
| 69 | } |
| 70 | |
| 71 | // RunInteractiveShell runs a shellcommand interactively |
| 72 | func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error) { |