How to use pexpect in python? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to use pexpect in python? (/thread-35405.html) |
How to use pexpect in python? - tiho_bg - Oct-30-2021 I would like to control a robot using pexpect. Here is my code: #!/usr/bin/env python from pexpect import pxssh import pexpect s = pxssh.pxssh() s.login('ubiquityrobot.local', 'ubuntu', 'ubuntu') print 'Start' s.sendline('rosrun simple_nav control.py') s.prompt() print(s.before) s.expect('Load Path Name?', timeout=5) s.sendline('yes') s.prompt() print(s.before) s.expect('Enter the name of the Path:', timeout=5) s.sendline('4') s.prompt() print(s.before) s.expect('Load Path Name? ') s.sendline('no') s.prompt() print(s.before) s.logout()The script is working fine till the end. Finally the script is closing with an error related with the timeout and eof. How to resolve this error? Please, help! RE: How to use pexpect in python? - Yoriz - Oct-30-2021 Maybe the following can help https://pexpect.readthedocs.io/en/stable/overview.html#special-eof-and-timeout-patterns Wrote:Special EOF and TIMEOUT patterns |