David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 1 | // Copyright 2013 Canonical Ltd. |
| 2 | // Licensed under the LGPLv3, see LICENCE file for details. |
| 3 | |
| 4 | package utils |
| 5 | |
| 6 | import ( |
| 7 | "os/exec" |
| 8 | ) |
| 9 | |
| 10 | // RunCommand executes the command and return the combined output. |
| 11 | func RunCommand(command string, args ...string) (output string, err error) { |
| 12 | cmd := exec.Command(command, args...) |
| 13 | out, err := cmd.CombinedOutput() |
| 14 | output = string(out) |
| 15 | if err != nil { |
| 16 | return output, err |
| 17 | } |
| 18 | return output, nil |
| 19 | } |