python ptyモジュールを使用して、いくつかのコマンドをターミナルエミュレーターに送信し、stdinとしての関数を使用して(ptyモジュールが必要とするように)、強制終了します。私は次のようなことを考えました
import pty
cmnds = ['exit\n', 'ls -al\n']
# Command to send. I try exiting as last command, but it doesn't works.
def r(fd):
if cmnds:
cmnds.pop()
# It seems is not executing sent commands ('ls -al\n')
else:
# Can i quit here? Can i return EOF?
pass
pty.spawn('/bin/sh', r)
ありがとうございました