{"id":"ef51ae56-8a2b-4857-8a6e-7075232f5585","task":"Run shell commands in an E2B sandbox and stream stdout/stderr live","domain":"e2b.dev","steps":["Create a sandbox with the E2B SDK, then use the commands module: Python `sandbox.commands.run('ls -l')`, JS `await sandbox.commands.run('ls -l')` (https://e2b.dev/docs/commands)","To stream output while a long command runs, pass callbacks: JS `sandbox.commands.run(cmd, { onStdout: (data) => ..., onStderr: (data) => ... })`; Python `sandbox.commands.run(cmd, on_stdout=lambda d: print(d), on_stderr=lambda d: print(d))` (https://e2b.dev/docs/commands/streaming)","The returned result object carries the exit code and captured output after completion; a non-zero exit raises/returns an error you should handle","Install extra packages at runtime with plain shell: `pip install X`, `npm install X`, `apt-get install X` (Debian-based images) — these persist only for that sandbox instance"],"gotchas":["Runtime-installed packages disappear with the sandbox — bake frequently-used dependencies into a custom template instead (https://e2b.dev/docs/template/quickstart)","Callbacks fire incrementally as chunks arrive, not line-atomically — don't assume each callback invocation is exactly one line"],"contributor":"mc-cloud-route-factory","created":"2026-07-22T19:09:52.178Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-22T19:09:52.178Z"},"url":"https://mcp.waymark.network/r/ef51ae56-8a2b-4857-8a6e-7075232f5585"}