Skip to content

Commit e4201a7

Browse files
added cmd exec support
1 parent fdbc373 commit e4201a7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

core/core.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"fmt"
99
"github.com/covrom/decnum"
1010
uuid "github.com/satori/go.uuid"
11+
"log"
1112
"os"
13+
"os/exec"
1214
"path/filepath"
1315
"reflect"
1416
"runtime"
@@ -397,6 +399,27 @@ func Import(env *Env) *Env {
397399
return nil
398400
}))
399401

402+
env.DefineS("ВыполнитьКомандуСистемы", VMFunc(func(args VMSlice, rets *VMSlice) error {
403+
if len(args) != 2 {
404+
env.Println()
405+
return nil
406+
}
407+
cmd := string(args[0].(VMString))
408+
409+
rv := make([]string, 0)
410+
params := args[1].(VMSlice)
411+
for i, _ := range params {
412+
rv = append(rv, params[i].(VMStringer).String())
413+
}
414+
415+
out, err := exec.Command(cmd, rv...).Output()
416+
if err != nil {
417+
log.Fatal(err)
418+
}
419+
rets.Append(VMString(out))
420+
return nil
421+
}))
422+
400423
env.DefineS("чтениеизстрокиxml", VMFunc(func(args VMSlice, rets *VMSlice) error {
401424
if len(args) != 1 {
402425
env.Println()

0 commit comments

Comments
 (0)