Request an invite
Docs menu

osmates vm exec

Run a program in a machine's guest.

Usage
osmates vm exec [<options>] <machine> [<arguments> ...]

The guest agent runs the program with its arguments as given, and no shell interprets them. Put the program after --, so its options stay its own. Run a shell for pipes and variables.

The output streams here as it comes, and Control-C interrupts the program. A machine that is starting is waited for.

The command exits with the program's status, 124 when it ran out of time, 125 when the command or the guest failed, or 128 plus the signal that ended it. When the guest agent stays silent for 10 minutes, the program is left running and the command names its PID.

Programs, jobs and exit statuses: https://osmates.com/docs/cli

Examples

sh
osmates vm exec dev -- ls -l /etc
osmates vm exec dev -- sh -c 'ls | wc -l'
osmates vm exec dev --detach -- make build

Arguments

<machine>Required

The machine's identifier or name.

--user <user>

The guest account to run as. Default: root, or LocalSystem in Windows.

With --desktop, the account expected at the screen. Windows takes an account only with --desktop.

--workdir <workdir>

The working directory. Default: the account's home, C:\ in Windows, or the user's profile with --desktop.

--env <name=value>Repeatable

Add a variable to the program's environment.

--timeout <timeout>

Seconds the program runs before it's killed. Default: no limit.

--desktop

Run as the user signed in at the screen, on their desktop.

--arch <arch>

Which code of a program built for several architectures runs.

One of arm64, x64.

-i, --stdin

Pass this command's standard input to the program.

--detach

Run it as a job and print the job's id.

Follow the job with osmates job.

--json

Print machine-readable JSON.

<arguments>Repeatable

The program and its arguments, after --.

JSON output

With --json, it prints an object with these fields.

JSON Schema: /schemas/0/cli/vm/exec.json

exitCodeinteger
signalinteger
standardErrorstring (base64)Required
standardErrorTruncatedbooleanRequired
standardOutputstring (base64)Required
standardOutputTruncatedbooleanRequired
timedOutbooleanRequired

With --detach

With --json and --detach, it prints an object with these fields.

JSON Schema: /schemas/0/cli/vm/exec.detach.json

createdAtstring (date-time)Required
creationStepsarray of strings or objects

Each item is one of preparing, verifying, unpacking, waitingForMacOS, waitingForMachine, installingWindows, settingUpTemplate, startingMacOS, installingGuestAgent, copyingXcode, settingUpXcode, downloadingSimulator, readingMachine, finishing, stopping, or an object that holds one key: downloading, copyingInstallationFile, installingMacOS, installingDesktop, installingLinux or convertingDisk.

creationSteps[].downloadingobject
creationSteps[].copyingInstallationFileobject
creationSteps[].installingMacOSobject
creationSteps[].installingDesktopobject
creationSteps[].installingLinuxobject
creationSteps[].convertingDiskobject
failureobject
failure.actionsarray of objectsRequired
failure.codestring
failure.kindstringRequired

One of failed, temporary, wrongInput.

failure.messagestringRequired
idstringRequired
kindstringRequired

One of create, resume, clone, delete, start, suspend, snapshot, revert, exec, run, transfer, clipboard, compact, grow-disk, workspace-push, workspace-diff, export-disk, move, update-macos, update-firmware, move-image-cache, template-push, template-pull.

machinestringRequired
outputobject with integer valuesRequired
output.stdoutinteger

At least 0.

output.stderrinteger

At least 0.

progressobject
progress.fractionnumber
progress.messagestringRequired
progress.stepstring or object

One of preparing, verifying, unpacking, waitingForMacOS, waitingForMachine, installingWindows, settingUpTemplate, startingMacOS, installingGuestAgent, copyingXcode, settingUpXcode, downloadingSimulator, readingMachine, finishing, stopping, or an object that holds one key: downloading, copyingInstallationFile, installingMacOS, installingDesktop, installingLinux or convertingDisk.

resultobject

Holds one key: machine, deleted, started, suspended, snapshot, reverted, process, run, transfer, clipboard, compaction, diskGrowth, workspace, workspaceDiff, exported, moved, macOSUpdate, firmwareUpdate, imageCacheMoved, pushed or pulled.

result.machineobject
result.deletedobject
result.startedobject
result.suspendedobject
result.snapshotobject
result.revertedobject
result.processobject
result.runobject
result.transferobject
result.clipboardobject
result.compactionobject
result.diskGrowthobject
result.workspaceobject
result.workspaceDiffobject
result.exportedobject
result.movedobject
result.macOSUpdateobject
result.firmwareUpdateobject
result.imageCacheMovedobject
result.pushedobject
result.pulledobject
statestringRequired

One of running, succeeded, failed, cancelled.

stepsarray of objects
steps[].endedstring (date-time)
steps[].problemstring
steps[].startedstring (date-time)Required
steps[].stepstringRequired

One of clone, start, signIn, workspace, copyIn, program, copyOut, diff, delete.

summarystringRequired
updatedAtstring (date-time)Required

Fields nested deeper are in the schema.

Exit statuses

Its exit status is one of these.

StatusMeaning
0The command did what it was asked.
1The command failed; with --json, standard error's last line is the error object.
64The command line is wrong, as ArgumentParser found before the command ran.
65What was given is wrong, found while the command ran; the same command fails until it changes.
75The same command can work later with nothing changed, as while an update finishes.
130Control-C cancelled what the command started.
0 to 255The program's own status; one outside 0 to 255, as a Windows program's can be, exits 1, and vm exec --json gives it whole.
124The program ran out of time.
125The command failed, apart from the program it runs.
129 to 192128 plus the signal that ended the program, as the guest numbers it.

Report a problem with this page