MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / shell

Method shell

common/provider/main.go:131–151  ·  view source on GitHub ↗

执行shell

(commands string)

Source from the content-addressed store, hash-verified

129
130// 执行shell
131func (prov *CodeCompileProvider) shell(commands string) (success bool, errout string) {
132 ctx, _ := context.WithTimeout(context.Background(), 7*time.Second)
133 cmdArgs := strings.Split(commands, " ")
134 if len(cmdArgs) <= 1 {
135 return false, "not enough arguments for compiler"
136 }
137 ret, err := utils.RunUnixShell(&structs.ShellOptions{
138 Context: ctx,
139 Name: cmdArgs[0],
140 Args: cmdArgs[1:],
141 StdWriter: nil,
142 OnStart: nil,
143 })
144 if err != nil {
145 return false, err.Error()
146 }
147 if !ret.Success {
148 return false, ret.Stderr
149 }
150 return true, ""
151}
152
153// 存储代码到文件
154func (prov *CodeCompileProvider) saveCode() error {

Callers

nothing calls this directly

Calls 2

RunUnixShellFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected