wasm change
This commit is contained in:
45
lib/run/exec_wasm.go
Normal file
45
lib/run/exec_wasm.go
Normal file
@@ -0,0 +1,45 @@
|
||||
//go:build wasm
|
||||
// +build wasm
|
||||
|
||||
package run
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"ems.agt/lib/log"
|
||||
)
|
||||
|
||||
func ExecCmd(command, path string) ([]byte, error) {
|
||||
log.Debug("Exec command:", command)
|
||||
|
||||
cmd := exec.Command("cmd", "/C", command)
|
||||
cmd.Dir = path
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("exe cmd error: ", err)
|
||||
return out, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func ExecOsCmd(command, os string) error {
|
||||
log.Debugf("Exec %s command:%s", os, command)
|
||||
|
||||
var cmd *exec.Cmd
|
||||
switch os {
|
||||
case "Linux":
|
||||
cmd = exec.Command(command)
|
||||
case "Windows":
|
||||
cmd = exec.Command("cmd", "/C", command)
|
||||
}
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("exe cmd error: ", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user