So I found out how to do this:
rows, cols = map(int, os.popen('stty size', 'r').read().split())
child.setwinsize(rows, cols)
سؤال
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?
المحلول 2
So I found out how to do this:
rows, cols = map(int, os.popen('stty size', 'r').read().split())
child.setwinsize(rows, cols)
نصائح أخرى
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:')