When using this script with a wide terminal (132x24), the display gets garbled when typing lines longer than 80 characters. Characters wrap back and overwrite the beginning of the line. Also, vi thinks the terminal is 80x24. An interactive SSH connection has no problems.
How can I get a pexpect login to behave like a normal interactive SSH login?
#!/usr/bin/python
import pexpect
import sys
hostname = sys.argv[1]
username = 'user1'
password = 'test123'
cmd = 'ssh '+username+'@'+hostname
c = pexpect.spawn(cmd)
c.expect('assword:')
c.sendline(password)
c.interact()
login using script
$ psh localhost
Last login: Sat Oct 17 01:51:53 2015 from localhost
$ tput cols
80
Interactive SSH login
$ ssh localhost
user1@localhost's password:
Last login: Sat Oct 17 01:53:52 2015 from localhost
$ tput cols
132