mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
add manage command
This commit is contained in:
25
cmd/exec.go
Normal file
25
cmd/exec.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func execCommand(cmd string) (string, error) {
|
||||
e := exec.Command("bash", "-c", cmd)
|
||||
out, err := e.CombinedOutput()
|
||||
if errors.Unwrap(err) == exec.ErrNotFound {
|
||||
e = exec.Command("sh", "-c", cmd)
|
||||
out, err = e.CombinedOutput()
|
||||
}
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
func execCommandStd(name string, args ...string) {
|
||||
e := exec.Command(name, args...)
|
||||
e.Stdout = os.Stdout
|
||||
e.Stdin = os.Stdin
|
||||
e.Stderr = os.Stderr
|
||||
_ = e.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user