Skip to Content
GuidesTerminalRun one command

Run a one-shot command

cmdop connect exec <machine> -- <command> runs one bounded command and returns its standard output, standard error, and exit status to the caller. Set --timeout in seconds for anything unattended; it defaults to 30. Note the scope before you build on it: this path resolves through the host’s own embedded relay, so it is self- and loopback-scoped rather than a cross-host runner.

Use one-shot execution for a bounded command whose standard output, standard error, and exit status should return to the caller. The current implementation resolves its target through this host’s embedded relay; it is self/loopback scoped and is not a general cross-host or CI execution path. To run work on another machine, attach interactively or ask that machine’s agent.

1. Confirm the target

cmdop connect --list --online

Use the displayed machine name in the command. For scripts that consume the roster, add --json and validate the selected machine instead of relying on an interactive picker.

2. Run the command

cmdop connect exec <machine> -- uptime

Everything after -- belongs to the target command. Keep the separator even when the command has no flags of its own.

Bound automation explicitly:

cmdop connect exec <machine> --timeout 60 -- <command> <arg>

-t / --timeout is a plain number of seconds and defaults to 30. Set it explicitly for anything an unattended script runs.

3. Handle failure as a result

Treat a non-zero remote exit, an unavailable machine, and a terminal-access credential failure as different outcomes. Do not retry a command that may have changed state until you know whether it started on the target.

For a hands-on shell, use interactive terminal access. For machine-agent work rather than shell execution, use Task execution.

Common questions

How do I run one command with Cmdop?

Use cmdop connect exec <machine> -- <command> for a bounded command whose output and exit status should return to the caller. Set --timeout explicitly for unattended scripts.

Is cmdop connect exec a cross-host runner?

No. This path resolves through this host’s embedded relay and is self- or loopback-scoped today. For another machine, attach interactively or ask that machine’s agent to do the work.

What should a script do with a non-zero exit?

Treat it as a command result, not a transport failure. Keep remote exit, unavailable machine, and credential failure separate, and do not retry a state-changing command until you know whether it started.

Last updated on