Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Python: Strange behaviour from pexpect

  • 17-07-2020 3:54pm
    #1
    Registered Users, Registered Users 2 Posts: 5,660 ✭✭✭


    I am using pexpect to check i am in the correct dir
        child = pexpect.spawn('ls')
        print(str(child.read()))
        child.expect("e")
    

    However it says it cannot find it despite the output of child.read() print being
    b"'~'   auto_copy_file.py   auto_upload_file.py   file   testout.txt\r\n"
    

    Not sure what is wrong. Full error below
        Error
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 166, in read_nonblocking
        s = os.read(self.child_fd, size)
    OSError: [Errno 5] Input/output error
    


Comments

  • Registered Users, Registered Users 2 Posts: 6,289 ✭✭✭Talisman


    The dreaded "[Errno 5] Input/output error" :eek:

    It has perplexed me at times and the solutions are never the same.

    When pexpect.expect spits the dummy it's usually with an EOF or TIMEOUT exception.

    The error message you are receiving suggests it's not the provided piece of code that is the cause of the issue, it's possibly in the OS or hardware level.

    What version of Python 3 are you running and on what environment?


Advertisement