Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Python: Strange behaviour from pexpect

  • 17-07-2020 04:54PM
    #1
    Registered Users, Registered Users 2 Posts: 5,761 ✭✭✭


    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: 7,188 ✭✭✭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