How to simulate terminal input without TIOCSTI in Python?

67 Views Asked by At

I want to run a command in a pseudo-terminal. I know that I could use fcntl.ioctl() with TIOCSTI but TIOCSTI has been removed from my system. However, there has to be a different way to do it, otherwise terminals just wouldn't work. This subject is not very well documented online, so even after some extensive googling I wasn't able to find anything useful.

Here is the code I used before, in case it would help:

import fcntl
import termios

def run_on_pty(pty, command):
    for char in command:
        fcntl.ioctl(pty, termios.TIOCSTI, char)


0

There are 0 best solutions below