Search code examples
pythonparamikopexpect

How can paramiko seek through a stream until a pattern is matched


I'd like to use paramiko to run a command and exit when a pattern appears. Now I do it using pexpect.expect(..., pattern = [pattern1, pattern2,...])

Is there a way to do using paramiko?


Solution

  • No, I don't think paramiko has that capability. In my experience the best approach is to send the pexpect script to the remote and execute it there with your paramiko. Fabric users run into this issue sometimes: https://stackoverflow.com/a/10007635/708221