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

Python: Strange behaviour from pexpect

  • 17-07-2020 4:54pm
    #1
    Registered Users Posts: 5,528 ✭✭✭


    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 Posts: 5,984 ✭✭✭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