Question

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?

Was it helpful?

Solution 2

So I found out how to do this:

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

OTHER TIPS

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:')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top