---
title: "ezgh sandboxes exec"
description: "Run a command in a sandbox."
---

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

# ezgh sandboxes exec

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh sandboxes exec <sandbox> [-i] [-t] [flags] -- command [args...]
```

Run a command in a sandbox and wait for it. Its output is written as it arrives, stdout to stdout and stderr to stderr. A suspended sandbox is resumed first. The command runs as the image's user in the image's working directory unless `--user` or `--workdir` says otherwise.

Without -i or -t, standard input isn't read, and the command is ended after `--timeout` seconds (1 to 840, default 300). -i sends standard input to the command until it ends, and has no timeout. -t also gives the command a terminal, for a shell: ezgh sandboxes exec -t &lt;sandbox&gt; -- sh.

The exit code is the command's own; 128 + n when signal n ended it; 124 when it timed out. A command is never run twice: if the connection is lost while it runs, ezgh says so and doesn't send it again.

Part of [`ezgh sandboxes`](/cli/reference/sandboxes).

## Examples

```sh
ezgh sandboxes exec build -- make test
ezgh sandboxes exec build --env MODE=test --workdir /srv -- sh -c 'make && make install'
tar -C ./src -cf - . | ezgh sandboxes exec -i build -- tar -C /srv -xf -
ezgh sandboxes exec -t build -- sh
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--env` | string, repeatable |  | an environment variable for the command, KEY=VALUE; repeat for more |
| `-i`, `--interactive` | boolean |  | send standard input to the command |
| `--timeout` | int | `300` | end the command after this many seconds, 1 to 840 (without -i or -t) |
| `-t`, `--tty` | boolean |  | give the command a terminal; implies -i |
| `--user` | string |  | the user it runs as |
| `--workdir` | string |  | the directory it runs in, an absolute path |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/sandboxes-exec/index.mdx
