Persistent pexpect sessions for automating interactive terminal applications. Use when you need to control interactive programs like ssh, databases, or debuggers that require user input.
Install
npx skillscat add mic92/mics-skills/pexpect-cli Install via the SkillsCat registry.
SKILL.md
Usage
# Start a new session
pexpect-cli --start
# 888d9bf4
# Start with a label
pexpect-cli --start --name ssh-prod
# a3f4b2c1
# Execute code in a session
pexpect-cli 888d9bf4 <<'EOF'
child = pexpect.spawn("bash")
child.sendline("pwd")
child.expect(r"\$")
print(child.before.decode())
EOF
# List sessions
pexpect-cli --list
# Stop a session
pexpect-cli --stop 888d9bf4Examples
SSH Session
session=$(pexpect-cli --start --name ssh-session)
pexpect-cli $session <<'EOF'
child = pexpect.spawn('ssh user@example.com')
child.expect('password:')
child.sendline('mypassword')
child.expect('\$')
print("Connected!")
EOF
# Run commands
pexpect-cli $session <<'EOF'
child.sendline('uptime')
child.expect('\$')
print(child.before.decode())
EOFDatabase Interaction
session=$(pexpect-cli --start --name db-session)
pexpect-cli $session <<'EOF'
child = pexpect.spawn('sqlite3 mydb.db')
child.expect('sqlite>')
child.sendline('.tables')
child.expect('sqlite>')
print("Tables:", child.before.decode())
EOFAvailable in Namespace
pexpect: The pexpect modulechild: Persistent child process variable (persists across executions)
See README.md for installation, monitoring, and advanced usage.