Enhance CronTool to support executing shell commands and update job handling

This commit is contained in:
Satyam Tiwari
2026-02-12 20:21:49 +05:30
parent 8968d58fed
commit 9c98c11351
4 changed files with 71 additions and 6 deletions

View File

@@ -8,10 +8,12 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
"time"
)
type ExecTool struct {
workingDir string
timeout time.Duration
@@ -91,7 +93,13 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]interface{}) (st
cmdCtx, cancel := context.WithTimeout(ctx, t.timeout)
defer cancel()
cmd := exec.CommandContext(cmdCtx, "sh", "-c", command)
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.CommandContext(cmdCtx, "powershell", "-NoProfile", "-NonInteractive", "-Command", command)
} else {
cmd = exec.CommandContext(cmdCtx, "sh", "-c", command)
}
if cwd != "" {
cmd.Dir = cwd
}