ssh_shell_exec
Execute a command on a remote SSH shell session and wait for its output, combining write, delay, and read into one call. Use it for sequential commands on embedded devices with timeouts.
Instructions
Send a command to an SSH shell session and wait for the output. Combines write + delay + read in one call. IMPORTANT: Do NOT issue concurrent commands to the same session_id — the SSH shell is a single channel; concurrent calls will interleave output and corrupt results. Always wait for the previous command to finish before sending the next one. If you need parallel execution, open multiple sessions via ssh_shell_open.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | Buffer clear flag: 1 (default) = clear buffer before collecting, 0 = append to buffer | |
| delay | No | Minimum polling duration in milliseconds (default: 1000), kept for backward compat | |
| command | Yes | The command to send to the shell | |
| session_id | Yes | The session ID returned by ssh_shell_open | |
| maxDuration | No | Execution cap in ms — ALWAYS estimate and pass a timeout matching the command's expected runtime; do not omit it. Suggested ranges: instant info commands (ls/ip addr/cat/echo) 3000-5000; medium tasks (apt install, dd, service restart) 30000-120000; long builds/flashes (make, flash_image) up to 600000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output. |