adb_shell_exec
Send a command to an open ADB shell session and capture the output in one call. Set a timeout that matches the task and wait for completion before issuing the next command to avoid interleaved results.
Instructions
Send a command to an ADB 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 ADB 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 adb_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 adb_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. |