{"library":"pexpect","install":[{"cmd":"pip install pexpect","imports":["import pexpect\n\n# Unix/Linux only — uses pty module\nchild = pexpect.spawn('ssh user@host', encoding='utf-8', timeout=30)\n\n# expect() returns index of matched pattern (or raises TIMEOUT/EOF)\nindex = child.expect(['password:', 'yes/no', pexpect.EOF, pexpect.TIMEOUT])\n\nif index == 0:\n    child.sendline('mysecretpassword')\nelif index == 1:\n    child.sendline('yes')\nelif index == 2:\n    print('Connection closed (EOF)')\nelif index == 3:\n    raise TimeoutError('SSH timed out')\n\n# Wait for shell prompt\nchild.expect(r'\\$')\nchild.sendline('ls -la')\nchild.expect(r'\\$')\nprint(child.before)"]}]}