| 11 | } |
| 12 | |
| 13 | func (ex ExecOperator) ExecuteStdio(command string, stream bool) (CommandRes, error) { |
| 14 | task := goexecute.ExecTask{ |
| 15 | Command: command, |
| 16 | Shell: true, |
| 17 | StreamStdio: stream, |
| 18 | } |
| 19 | |
| 20 | res, err := task.Execute(context.Background()) |
| 21 | if err != nil { |
| 22 | return CommandRes{}, err |
| 23 | } |
| 24 | |
| 25 | return CommandRes{ |
| 26 | StdErr: []byte(res.Stderr), |
| 27 | StdOut: []byte(res.Stdout), |
| 28 | ExitCode: res.ExitCode, |
| 29 | }, nil |
| 30 | } |
| 31 | |
| 32 | func (ex ExecOperator) Execute(command string) (CommandRes, error) { |
| 33 | return ex.ExecuteStdio(command, true) |