mirror of https://github.com/1Panel-dev/1Panel
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.
19 lines
307 B
19 lines
307 B
package cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"os/exec"
|
|
)
|
|
|
|
func Exec(cmdStr string) (string, error) {
|
|
cmd := exec.Command("bash", "-c", cmdStr)
|
|
var stdout, stderr bytes.Buffer
|
|
cmd.Stdout = &stdout
|
|
cmd.Stderr = &stderr
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
return stderr.String(), err
|
|
}
|
|
return stdout.String(), nil
|
|
}
|