2017-07-05 17:14:11 +02:00
|
|
|
package shared
|
2017-06-26 21:42:47 +02:00
|
|
|
|
2017-06-29 21:43:12 +02:00
|
|
|
import (
|
2017-06-28 23:13:56 +02:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2017-06-26 21:42:47 +02:00
|
|
|
)
|
|
|
|
|
2017-06-30 19:00:25 +02:00
|
|
|
// Executes a command then returns true for success, false if there was an error, err is either nil or the error.
|
|
|
|
func execCmd(cmdExecName string, args []string, workingDir string) (success bool, err error) {
|
2017-06-28 23:13:56 +02:00
|
|
|
cmd := exec.Command(cmdExecName, args...)
|
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
cmd.Stderr = os.Stderr
|
2017-07-06 02:48:40 +02:00
|
|
|
cmd.Stdin = os.Stdin
|
2017-06-28 23:13:56 +02:00
|
|
|
cmd.Dir = workingDir
|
2017-06-30 19:00:25 +02:00
|
|
|
err = cmd.Run()
|
2017-07-21 22:38:52 +02:00
|
|
|
ecode := 0
|
|
|
|
if err != nil {
|
|
|
|
ecode = 1
|
|
|
|
}
|
|
|
|
LogDebug("execCmd: %v %v in %v had exitCode %v\n", cmdExecName, args, workingDir, ecode)
|
|
|
|
if err != nil {
|
|
|
|
LogDebug("execCmd: error was %v\n", err)
|
|
|
|
}
|
|
|
|
success = (ecode == 0)
|
2017-06-30 19:00:25 +02:00
|
|
|
return
|
2017-06-26 21:42:47 +02:00
|
|
|
}
|