You need the editor or admin role in your workspace. The examples use the CLI. Over MCP, an agent does the same with exec_computer.
Use the demo computer from Create a computer, with an
image that includes sh.
Check the computer
nevia status demoThe state must be ready, with no pending transition. If the computer is sleeping,
wake it first. Exec does not wake a computer.
Run the command
Print a message inside the computer's primary container:
nevia exec demo --entrypoint '' -- sh -c 'echo hello'You should see:
helloThe arguments after -- replace the image's CMD and go to the image's ENTRYPOINT.
--entrypoint '' clears the ENTRYPOINT, so your command runs as typed on every
image. Without it, an image whose ENTRYPOINT is an application receives your command
as that application's arguments. The default image uses a launcher entrypoint that
forwards supplied commands, so --entrypoint '' is optional there.
With no arguments, the image's own ENTRYPOINT and CMD run:
nevia exec demoExec does not start a shell, so wrap the command in sh -c when you need shell syntax.
For an interactive shell, use nevia shell.
Run through or replace the entrypoint
Without --entrypoint, the arguments go to the image ENTRYPOINT. On an image whose
ENTRYPOINT is its application, that is how you pass it options:
nevia exec demo -- --version--entrypoint PROGRAM replaces the image ENTRYPOINT for one command. The arguments
after -- follow it:
nevia exec demo --entrypoint /bin/busybox -- ls /The CLI streams the command's output and exits with its status. Check the exit code right after the command:
echo $?0 means the command succeeded.
Wait for the command to finish before you sleep, checkpoint or delete the computer. Each of those can interrupt an exec session. See Computer lifecycle states.
nevia exec lists the command options. The
exec API reference covers request limits
and errors.
Handle a failed command
Run a command that writes to stderr and exits with status 23:
nevia exec demo --entrypoint '' -- sh -c 'printf "example failure\n" >&2; exit 23'
echo $?You should see:
example failure
23The command ran and failed. Its earlier changes to files or other state remain.
Repeating nevia exec runs it again, so check those effects before retrying.
A command that cannot start is a different failure. Invalid startup input, such
as a missing executable, reports validation_failed; an internal startup failure
reports command_start_failed. Fix the reported cause before retrying. If the
connection drops, the command may still be running: closing the connection does
not stop it.
For JSON API and MCP callers, a nonzero exit or signal produces command_failed,
with output and exit status in error.details. The CLI streams the output and
returns the command's exit status. If the exit code is zero and a signal killed
the command, the CLI returns 128 + signal.
Set environment variables
Each run gets the computer's stored env, with secrets and variables at their current
values. Add -e KEY=value to set or override a variable for one run:
nevia exec demo -e LOG_LEVEL=debug --entrypoint '' -- ./run.shUse -e secrets.NAME or -e variables.NAME to take a value from the workspace. Nevia
resolves it on each run. For the full rules, see
Computer environment variables. To manage the values,
see Give computers secrets and variables.
Interactive execution
To run a program with a terminal, add -t:
nevia exec demo -t --entrypoint '' -- python-t enables interactive input and forwards terminal resizes. It needs a local terminal
for input and output. To stream input without a
terminal, use -i alone:
tail -f app.log | nevia exec demo -i --entrypoint '' -- ./ingestEach nevia exec -i or -t starts a session with the same env as one-shot exec. See
Interactive sessions
for what a session URL can reach.
Sessions expire after one hour. Set another duration, up to 12 hours, with --ttl:
nevia exec demo -t --ttl 2h --entrypoint '' -- pythonFor the computer's shell, use nevia shell instead of
nevia exec -t -- sh: it resolves the image's SHELL, clears the ENTRYPOINT and
picks a terminal on its own.