github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/utils/command.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, 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 }