2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

feat: php支持74和80

This commit is contained in:
耗子
2024-11-01 21:42:20 +08:00
parent 336a9bc675
commit b96c6ad899
17 changed files with 582 additions and 1298 deletions

View File

@@ -16,7 +16,23 @@ import (
"github.com/creack/pty"
)
// Execf 执行 shell 命令
// Exec 执行 shell 命令
func Exec(shell string) (string, error) {
_ = os.Setenv("LC_ALL", "C")
cmd := exec.Command("bash", "-c", shell)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return strings.TrimSpace(stdout.String()), fmt.Errorf("run %s failed, err: %s", shell, strings.TrimSpace(stderr.String()))
}
return strings.TrimSpace(stdout.String()), nil
}
// Execf 安全执行 shell 命令
func Execf(shell string, args ...any) (string, error) {
if !preCheckArg(args) {
return "", errors.New("command contains illegal characters")