Image 01
profile-image

sabutilnik

ricardo guerra Madrid
Easy SSH Connection

Plasma 4 Extensions by vgevorgyan 52 comments

I've modified runPassword.py to solve that problem, now it looks like this:


import signal, termios, struct, fcntl,time
global_pexpect_instance = None

def sigwinch_passthrough (sig, data):
# Check for buggy platforms (see pexpect.setwinsize()).
if 'TIOCGWINSZ' in dir(termios):
TIOCGWINSZ = termios.TIOCGWINSZ
else:
TIOCGWINSZ = 1074295912 # assume
s = struct.pack ("HHHH", 0, 0, 0, 0)
a = struct.unpack ('HHHH', fcntl.ioctl(sys.stdout.fileno(), TIOCGWINSZ , s))
global global_pexpect_instance
global_pexpect_instance.setwinsize(a[0],a[1])

try:
import pexpect
import sys

command = sys.argv[1]
password = sys.argv[2]
child = pexpect.spawn(command)
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
global_pexpect_instance = child
child.expect("assword:")
child.sendline(password)
child.interact()
except ImportError:
print "Module pexpect not found, please install pexpect package."

i hope it works for you.
- Oct 31 2011