SSHScript and Pytermgui
Pytermgui is an excellent Python TUI framework. This example shows that it can get data from the remote console easily by sshscript. And the difference is only one line (connecting or not) between getting data from localhost or remote host.

file: demopytermgui.spy
import pytermgui as ptg
# comment-out the next line to get free memory of localhost
$.connect('user@host-a')
def macro_freememory(fmt: str) -> str:
# We do not need to call $hostname every time.
# It is here just for proving that it is actually executing on remote host.
$ hostname
hostname = $.stdout.strip()
# collect data of free memory by "vmstat"
$ vmstat 1 1
amount = $.stdout.split("\n")[2].split()[3]
return f'host "{hostname}" has free memory {amount}'
ptg.tim.define("!freememory", macro_freememory)
with ptg.WindowManager() as manager:
manager.layout.add_slot("Body")
manager.add(
ptg.Window("[bold]The free memory is:[/]\n\n[!freememory 75]%c", box="EMPTY")
)
execution examples
$sshscript demopytermgui.spy
$sshscript demopytermgui.spy --verbose
$sshscript demopytermgui.spy --debug
Screenshot of execution:

Last Updated: 2026-07-25 16:59:40
Table of contents
- SSHScript v3.1 Documentation
- Accounts (legacy URL)
- Checking the syncing status of two MySQL servers
- Getting Started with SSHScript
- Q: What can it do that Netmiko doesn’t do? (origin)
- SSHScript Documents
- SSHScript v2.0 CLI(Draft)
- SSHScript v2.0 Commands Execution and Console
- SSHScript v2.0 Console of sudo and su
- SSHScript v2.0 Getting Started
- SSHScript v2.0 Interactive Commands and Foreground Commands
- SSHScript v2.0 Make Connections
- SSHScript v2.0 Recipes
- SSHScript v2.0 Reference Guide
- SSHScript v2.0 Stdout, Stderr and Exitcode
- SSHScript v2.0 Threading Support
- SSHScript v2.0 Upload and Download Files
- SSHScript v2.0.2 Release Notes
- SSHScript v3.0 Interactive and Foreground Commands
- SSHScript v3.0 Reference Guide
- SSHScript v3.0.0 Release Notes
- SSHScript v3.1
- SSHScript vs. Ansible
- 用 Python 作系統自動化