MCPcopy Create free account
hub / github.com/Xenov-X/csbot / executeRunUnder

Method executeRunUnder

workflow/executor_spawn.go:52–78  ·  view source on GitHub ↗

executeRunUnder executes a command with specified PID as parent

(ctx context.Context, client *csclient.Client, beaconID string, action Action)

Source from the content-addressed store, hash-verified

50
51// executeRunUnder executes a command with specified PID as parent
52func (e *Executor) executeRunUnder(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) {
53 pidVal, ok := action.Parameters["pid"]
54 if !ok {
55 return "", fmt.Errorf("pid parameter required for run_under")
56 }
57 var pid int
58 switch v := pidVal.(type) {
59 case float64:
60 pid = int(v)
61 case int:
62 pid = v
63 default:
64 return "", fmt.Errorf("pid must be a number")
65 }
66
67 command, ok := action.Parameters["command"].(string)
68 if !ok {
69 return "", fmt.Errorf("command parameter required for run_under")
70 }
71 args, _ := action.Parameters["args"].(string) // optional
72
73 resp, err := client.RunUnder(ctx, beaconID, pid, command, args)
74 if err != nil {
75 return "", err
76 }
77 return e.waitForOutput(ctx, client, resp.TaskID)
78}
79
80// executeRunNoOutput executes a command without blocking or returning output
81func (e *Executor) executeRunNoOutput(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) {

Callers 1

executeActionMethod · 0.95

Calls 1

waitForOutputMethod · 0.95

Tested by

no test coverage detected