import pexpect, time c = pexpect.spawn('ssh -q -o StrictHostKeyChecking=no root@210.16.161.214', encoding='utf-8', timeout=30) c.expect('password:') c.sendline('XHR521yhf') c.expect('[$#]') c.sendline('echo "=== PNPM ===" && tail -3 /tmp/pnpm_install.log 2>/dev/null && echo "=== PG ===" && docker images postgres:16 --format "{{.Size}}" 2>/dev/null || echo STILL_PULLING && echo "=== PS ===" && ps aux | grep -E "pnpm|docker pull" | grep -v grep | awk "{print \$2,\$11}" || echo DONE') c.expect('[$#]') print(c.before.strip()[-1000:]) c.sendline('exit')