> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# anona-compute exec

> Run a command in a sandbox

```text
Run a command in a running sandbox and stream its output. anona-compute exits with
the command's exit code. With one argument the command is a shell string
(anona-compute exec ID -- 'ls | wc -l'); several arguments are quoted and joined.

The command's stdin is empty unless -i/--stdin is given; with -i the CLI's
stdin is streamed to it and closed at EOF:

  tar -cz src | anona-compute exec -i ID -- 'tar -xz -C /home/user'

-b/--background starts the command and prints its PID. Its stdout and
stderr are kept in the sandbox (under /tmp/anona-compute-bg); read them with
anona-compute output ID PID (-f to follow) and list processes with
anona-compute ps ID.

With --json, output is one object per line: {"type":"stdout"|"stderr","data":...}
and finally {"type":"exit","exit_code":N}.

Exit codes:
  0    success
  1    general error
  2    usage error (bad flag, argument or value)
  3    not signed in, or the credential was refused (HTTP 401/403)
  4    not found (HTTP 404)
  5    plan limit or rate limit (HTTP 429, or error_code plan_limit_exceeded)
  exec and run pass the remote command's exit status through unchanged
  (0-255; 130 after Ctrl-C) and exit 125 when anona-compute itself failed,
  for any of the reasons 1-5 above; their --json error keeps that detailed
  code in "cli_code".
```

## Usage

```text
anona-compute exec SANDBOX_ID -- COMMAND [ARGS...] [flags]
```

**Aliases:** `exec`, `ex`

## Flags

| Flag | Type | Description |
| - | - | - |
| `--background`, `-b` | | start the command, print its PID and return; read its output later with anona-compute output |
| `--cmd-timeout` | duration | stop waiting for the command after this long (0 = no limit) |
| `--cwd`, `-w` | string | working directory |
| `--env`, `-e` | stringArray | environment variable KEY=VALUE for the command (repeatable) |
| `--help`, `-h` | | help for exec |
| `--stdin`, `-i` | | send this terminal's stdin to the command (closed at EOF) |
| `--user`, `-u` | string | user to run as (default: the sandbox's default user) |

Global flags (`--api-key`, `--api-url`, `--json`, `--output`, `--profile`, `--request-timeout`, `--verbose`) work on every command; see [anona-compute](/docs/cli/reference/anona-compute.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.