# run_shell_command

> Run one shell command on the hosting account AS the account user over SSH (never as an administrator) and return `{command, cwd, exitCode, stdout, stderr, truncated,…

- Tier: D
- Required scope: shell:hosting
- Annotations: destructiveHint
- Docs: https://api.inleed.com/tools/run-shell-command

## Description

Run one shell command on the hosting account AS the account user over SSH (never as an administrator) and return `{command, cwd, exitCode, stdout, stderr, truncated, timedOut, durationMs}`. Use it for what the structured tools cannot do: read and summarise logs with grep/awk/tail, inspect or clean up files, repair a site, run wp/composer/npm/git/php. It is bash on the node, so pipes and redirects work; the command runs non-interactively (no editors, no prompts, no background daemons, no sudo) with a hard `timeout` (max 45 s) and capped output — keep it small with `tail`, `head`, `grep -c`, `wc -l`. Pass `cwd` (a home-relative path like `/domains/example.se/public_html`) instead of `cd`.

## Input schema

- `input` — string (required). A domain, email address, website URL, numeric service id, or hosting-account username the customer actually owns. Resolved to the owning account automatically; the resolved target is echoed back in the response.
- `command` — string (required). The bash command line to run, exactly as the customer would type it (≤ 4000 chars). Pipes, redirects and &amp;&amp; are fine; interactive programs are not.
- `cwd` — string. Working directory, relative to the account home (/ = home), e.g. /domains/example.se/public_html.
- `timeout` — integer. Seconds before the command is killed (1–45, default 30). Keep commands short; a long job should be narrowed, not extended.
- `attempt_key` — string. Optional idempotency key for a command that holds for confirmation.

## Example call

```json
{
  "name": "run_shell_command",
  "arguments": {
    "input": "example.se",
    "command": "/usr/bin/php /home/inleed42/backup.php"
  }
}
```

