Skip to main content
100%

Gist 3265e265f71ea51a81e03416e00e8e94

✓ Published0🌍 Public
HHerst
Last edited Jan 29, 2026
Created on Jan 29, 2026

This example shows a shell script that establishes a serial connection to a running QEMU virtual machine. It demonstrates how to bridge a QEMU UNIX socket to a pseudo-terminal using `socat`, then attaches that terminal to a `screen` session for interactive access. The script first attempts to reattach to an existing screen session named `qemu-serial`; if that fails, it launches `socat` in the background to link the socket to a PTY, starts `screen` with that PTY, and cleans up `socat` once screen exits. It relies on `set -euo pipefail` for strict error handling and checks screen’s process list to decide whether to kill the background `socat`. The code uses standard shell utilities (`screen`, `socat`, `grep`) without any external data libraries.

AI-generated description

Similar vizzes