I'm currently trying to send binary data via pexpect. For some reason, the data goes through only a search, with the exception of 0x04, which is simply skipped. I traced the pexpect call to determine that everything that happens is the os.write () call on the file descriptor opened from the pty.fork () command.
Any ideas?
(sample code that illustrates the problem)
import os, pty, sys pid, child_fd = pty.fork() if pid: # Parent os.write(child_fd, b"'\x04hmm\x04'\n") buf = os.read(child_fd, 100) print buf else: # Child text = sys.stdin.readline() print ''.join(["%02X " % ord(x) for x in text])
Result:
$ python test.py 'hmm' 27 68 6D 6D 27 0A
source share