Commands · reference
vmlab clipboard
vmlab clipboard reads or writes a guest's clipboard over the guest agent channel. No guest network is involved, so it works on a machine with no NIC at all.
| Subcommand | Meaning |
|---|---|
| get | Write the guest clipboard to stdout, with no trailing newline added. |
| set | Set the guest clipboard from TEXT, or from stdin when TEXT is omitted. |
| -h, --help | Print help. |
Both subcommands take a machine reference of the form [lab/]machine. A bare name is resolved against the lab in the current directory, and the lab daemon is started if none is running. The qualified form addresses a lab that is already running from any directory and never starts one. The machine must be running with an agent that advertises the clipboard feature; see vmlab machine capabilities. The agent advertises it only where it can reach a display server, so on a headless guest both subcommands refuse with the guest agent has no clipboard.
A Windows agent always advertises clipboard, because someone can log on at any time. The Windows clipboard belongs to an interactive session, so on a guest at the lock screen with nobody logged on both subcommands refuse at once:
winsrv: no one is logged on to the desktop; the Windows clipboard belongs to an interactive session (it works once a user logs on)Log on at the console (vmlab console) and run the command again. A locked session still counts as logged on, so the clipboard keeps working after the screen locks.
vmlab clipboard get
| Option | Meaning |
|---|---|
| <MACHINE> | The machine, as [lab/]name. |
| --json | Emit the raw JSON string instead of the bare text. |
| -h, --help | Print help. |
The guest's clipboard text is written to stdout byte for byte. No newline is appended, so what you pipe on is exactly what the guest held. With --json the text is printed as one JSON string literal instead. The agent is given 10 seconds to answer.
vmlab clipboard set
| Option | Meaning |
|---|---|
| <MACHINE> | The machine, as [lab/]name. |
| [TEXT] | The text to copy. Omit it to read stdin. |
| --json | Emit the raw JSON reply instead of a confirmation. |
| -h, --help | Print help. |
With a TEXT argument that text becomes the guest's clipboard. Without one, stdin is read to end of file and passed through verbatim, trailing newline included, so vmlab clipboard get a | vmlab clipboard set b round-trips exactly. Use echo -n when you do not want the newline echo adds. On success the verb prints `copied N bytes to "<machine>" clipboard; with --json it prints the daemon's reply, which is true`.
The confirmation is printed only after the agent reports that the text is on the guest clipboard; the agent is given 10 seconds to report. An agent that predates the clipboard_reply feature sends no such report, so against one the confirmation means only that the request was sent.
Examples
Move a password from one guest to another without typing it:
| Paste a host file's content into a guest:
Read a guest's clipboard into a shell variable:
token=Exit status
Exit status is 0 when the clipboard was read or written. Exit 4 (not_found) means the lab declares no machine by that name. Exit 6 (unsupported) means the agent lacks the clipboard feature. A machine that is not running, an agent that is not answering, a guest the agent cannot reach the clipboard of (nobody logged on to a Windows desktop), and a request that times out all exit 1 (failed). A qualified reference to a lab that is not running exits 1. A usage error exits 2.