Skip to content
github-actions[bot] edited this page Feb 12, 2026 · 3 revisions

fm shell

Spawn shell for the bench or execute a command.

Supports multiple input modes:

  • Interactive shell (no input)
  • Command execution (-c flag)
  • Heredoc/piped commands (stdin)
  • Passthrough args (-- syntax)

The --bench-console flag provides three modes:

  • Interactive: Opens IPython console with Frappe context (no -c or piped input)
  • Script: Executes piped Python code (stdin)
  • Inline: Executes -c command directly

In interactive mode, provides full terminal support. Exit code from executed commands is preserved.

Usage:

$ fm shell BENCHNAME [OPTIONS]

Arguments:

  • BENCHNAME: Name of the bench.

Options:

  • --command: Execute command and exit [default: -c]
  • --user: User to connect as
  • --service: Service to connect to
  • --shell-path: Shell path (e.g., /bin/bash, /bin/sh)
  • --run: Use 'docker compose run --rm'
  • --bench-console: Open bench console with Frappe context (interactive IPython or execute code via -c/stdin)
  • --site: Site name for bench console (defaults to benchname if not specified)

Examples:

Open interactive shell as frappe user

fm shell mybench

Open shell as root user

fm shell mybench --user root

Execute single command

fm shell mybench -c "bench --version"

Execute commands from heredoc

fm shell mybench <<'EOF'
ls -la
bench --version
EOF

Open shell in nginx container

fm shell mybench --service nginx --user nginx

Run command with passthrough syntax

fm shell mybench -- bench migrate

Open interactive bench console with IPython

fm shell mybench --bench-console

Open bench console for specific site

fm shell mybench --bench-console --site mysite.localhost

Execute Python code in Frappe context

fm shell mybench --bench-console -c "import frappe; print(frappe.__version__)"

Execute Python script from heredoc in Frappe context

fm shell mybench --bench-console <<'EOF'
import frappe
print(frappe.__version__)
EOF

Execute Python script file in Frappe context

fm shell mybench --bench-console < script.py

Clone this wiki locally