3 ms·
I wish there was something like expect that was like, "ok I've done what I needed to init, now get out of the way." I've always had to create a loop that just r
by mzs 7y ago
I wish there was something like expect that was like, "ok I've done what I needed to init, now get out of the way." I've always had to create a loop that just reads and writes everything eventually. Maybe I could ldpreload a tcl interpreter and change some pointers but yikes.
- solresol 7y agoWhat's wrong with the interact function?
- _ph_ 7y agoIsn't that what interact is meant to do? https://wiki.tcl-lang.org/page/interact https://wiki.tcl-lang.org/page/interact
- jraph 7y agoIf I understood correctly, you may be able to do that using pexpect and the interact method. import struct, fcntl, termios, signal, sys def sigwinch_passthrough (sig, data): s = struct.pack("HHHH", 0, 0, 0, 0) a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ , s)) if not child.closed: child.setwinsize(a[0],a[1]) child = pexpect.spawnu("sh", args, encoding='utf-8', logfile=sys.stdout) signal.signal(signal.SIGWINCH, sigwinch_passthrough) child.expect_exact("...") child.logfile = None # Otherwise, interact raises an Exception child.send("...\n") child.interact()