shell_execute
Run a shell command on macOS synchronously and return exit code, stdout, and stderr. Specify command, working directory, timeout, stdin, and environment variables for bounded tasks.
Instructions
Run a shell command on this Mac and wait for it to finish.
Runs through a login shell, so pipes, globs, redirects, &&, $VARS, heredocs and shell functions all work — pass the command exactly as you would type it in Terminal. Use this for anything that finishes within the timeout.
For work that outlives the timeout (builds, installs, dev servers) use shell_start instead.
Args: command: Shell command line, e.g. "ls -la ~/Documents | head -20". cwd: Working directory. Defaults to the user's home. ~ is expanded. timeout: Seconds before the process tree is killed. Default 120, max 3600. Zero or negative means "use the default", not "give up immediately". stdin: Text piped to the command's stdin. env: Extra environment variables, merged over the inherited environment.
Returns: exit_code, stdout, stderr, duration_s, cwd, timed_out, and stdout_truncated / stderr_truncated flags.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| env | No | ||
| stdin | No | ||
| command | Yes | ||
| timeout | No |