Pregunta

In Perl's expect module, I can do this:

my $login = new Expect;
$login->slave->clone_winsize_from(\*STDIN);

What's the equivalent in Python? I see an option for child.setwinsize(row, column), but how do I clone it from STDIN like I can do in Perl?

¿Fue útil?

Solución 2

So I found out how to do this:

rows, cols = map(int, os.popen('stty size', 'r').read().split())
child.setwinsize(rows, cols)

Otros consejos

You can use raw_input(), readline() or sys.stdin.readline() depending on how you get your stdin.

Tks @nerdinary,

its works for me:

stconn = 'ssh -o StrictHostKeyChecking=no -o ForwardX11=no root@server'    
conn = pexpect.spawn(stconn, encoding='utf-8')
conn.timeout = 10
rows, cols = map(int, os.popen('stty size', 'r').read().split())
conn.setwinsize(rows, cols)
conn.expect('password:')
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top