Skip to main content
The shell is an interactive terminal over WebSocket. Use it for interactive work. When you need clean output and an exit code, use execute instead.

Open a shell

In Python, shell() returns a websocket-client connection. Send and receive the JSON messages below as text. In Go, use the SendShellInput, ResizeShell and RecvShellMessage helpers.

Messages

Every message is a JSON text frame. Send only the two client message types above. The sandbox ignores raw text, binary frames and other types.

Session behavior

  • The shell runs bash as root, with HOME=/root.
  • Output is raw terminal output. It includes the echo of your input, \r\n line endings and control characters, and stderr is merged into stdout.
  • One command’s output can arrive in several stdout messages. Keep reading until you see the prompt, or set a read timeout.
  • Disconnecting and reconnecting returns you to the same session. The working directory and exported variables are kept.
  • Only one connection can be attached at a time. A second connection receives connected, then an error message, and no output. The first connection is not affected.
Close the connection when you are done. Do not run exit: it ends the session, and every later shell connection to that sandbox receives connected and then closed straight away.