示例#1
0
func RunSilentCommand(command string, args []string) {
	out, err := exec.Command(command, args...).Output()
	res := models.Response{Result: string(out), Status: 200}
	if err != nil {
		res.Error = err.Error()
	}
	res.Log()
}
示例#2
0
func RunCommand(w http.ResponseWriter, command string, args []string) {
	out, err := exec.Command(command, args...).Output()
	res := models.Response{Result: string(out), Status: 200}
	if err != nil {
		res.Status = 500
		res.Error = err.Error()
	}
	res.Respond(w)
}