You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
668 B
32 lines
668 B
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os/exec"
|
|
)
|
|
|
|
func CMDBool(name string, arg []string) bool {
|
|
cmdExec := exec.Command(name, arg...)
|
|
log.Println(cmdExec.String())
|
|
out, err := cmdExec.CombinedOutput()
|
|
if err != nil {
|
|
log.Println(string(out))
|
|
log.Printf("cmd.Run() failed with %s", err)
|
|
return false
|
|
}
|
|
fmt.Printf("combined out:%s", string(out))
|
|
return true
|
|
}
|
|
|
|
func CMDString(name string, arg []string) (string, error) {
|
|
cmdExec := exec.Command(name, arg...)
|
|
out, err := cmdExec.CombinedOutput()
|
|
return string(out), err
|
|
}
|
|
|
|
func CMDShellTrick(cmd string) (string, error) {
|
|
out, err := exec.Command("sh", "-c", cmd).Output()
|
|
return string(out), err
|
|
}
|