(executable string, args []string)
| 35 | } |
| 36 | |
| 37 | func Exec(executable string, args []string) (string, error) { |
| 38 | path, err := exec.LookPath(executable) |
| 39 | if err != nil { |
| 40 | log.Warning("executable %s not found in $PATH", executable) |
| 41 | return "", err |
| 42 | } |
| 43 | |
| 44 | raw, err := exec.Command(path, args...).CombinedOutput() |
| 45 | |
| 46 | log.Debug("exec=%s args=%v ret_err=%v ret_out=%s", path, args, err, string(raw)) |
| 47 | if err != nil { |
| 48 | return str.Trim(string(raw)), err |
| 49 | } else { |
| 50 | return str.Trim(string(raw)), nil |
| 51 | } |
| 52 | } |