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

# ubx exec

> Run a command with stack outputs injected as environment variables (experimental).

`ubx exec` runs a command with all stack outputs injected as environment variables. Output keys are uppercased and non-alphanumeric characters replaced with underscores — matching `ubx output --format env`.

## Usage

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx --experimental exec -- <command> [args...]
```

## Requirements

* `--experimental` global flag required
* A deployed stack with outputs in `.ubx/`

## Examples

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx --experimental exec -- env | grep VPC
ubx --experimental exec -- psql $DATABASE_URL
ubx --experimental exec -- bash -c 'echo $BUCKET_NAME'
ubx --experimental exec -- terraform plan
```

## Environment injection

Stack outputs become environment variables:

* Keys uppercased: `vpc_id` → `VPC_ID`
* Non-alphanumeric chars replaced with `_`: `db.endpoint` → `DB_ENDPOINT`
* Secrets are **not** injected (shown as `[sensitive]` in output)
* Objects and arrays become compact JSON strings

The child process inherits the full parent environment plus the injected output variables.

## Experimental flag

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx --experimental exec -- psql $DATABASE_URL
```

Without `--experimental`:

```
ubx exec is experimental — run with 'ubx --experimental exec' to enable
```

## Exit codes

The exit code from the child command is propagated. If the command cannot be started, ubx exits 1.

## Related commands

* [`ubx shell`](/v1/cli/shell) — interactive shell with outputs injected
* [`ubx output`](/v1/cli/output) — display outputs in various formats
