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?
您可以使用raw_input()
, readline()
或sys.stdin.readline()
具体取决于获得标准输入的方式。
So I found out how to do this:
rows, cols = map(int, os.popen('stty size', 'r').read().split())
child.setwinsize(rows, cols)
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:')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.