# ry exec

> Run a command in a running machine and exit with its exit code (the command goes after --).

```text
ry exec [options] [app] -- <command> [args...]
```

## Arguments

- `[app]`: The app (default: "app" from rytiv.json in this directory or above).

## Options

- `-m, --machine <id>`: Which machine (default: a running one of the app).
- `-i, --interactive`: Pass this terminal's stdin to the command.
- `-t, --tty`: Allocate a terminal in the machine (with -i: an interactive shell).
- `-e, --env <KEY=VALUE>`: Env for this command only (repeatable).
- `--dir <path>`: Working directory in the machine (absolute).
- `--timeout <seconds>`: Stop the command after this many seconds (exit code 124).
- `--no-wake`: Fail instead of waking a sleeping machine.

## Example

```bash
ry exec web -- ls -la /app
ry exec dev-1 --dir /data -- git status
```

From `ry exec --help`:

```text
Examples:
  ry exec shop -- ls -la /app
  ry exec -m m-1234 -e DEBUG=1 --dir /srv -- ./migrate.sh
  ry exec shop -it -- sh

Exit code: the command's own; 128+n if a signal ended it; 124 on --timeout; 127/126 if it
was not found / not executable; 255 for everything of ry's own (with a `ry:` line on stderr).
Ctrl-C sends SIGINT, a second one SIGTERM, a third SIGKILL.
```
