Mike Frysinger <vap...@gentoo.org> writes: > you could accomplish all of this with python alone. are you aware of > the pexepct module ? http://pexpect.sourceforge.net/
The implementation below is in python using pexepect and it works fine. It still doesn't answer the question why this doesn't work in bash? > if you're still set on this amalgamation, then might i suggest looking > into the expect-lite package ? http://expect-lite.sourceforge.net/ expect-lite is still expect, so why do you recommend using this instead of what I'm using now? The following is the code in python: #!/usr/bin/env python import pexpect import struct, fcntl, os, sys, signal import urlparse 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]) url = urlparse.urlparse(sys.argv[1]); ssh_newkey = 'Are you sure you want to continue connecting' p=pexpect.spawn('ssh'+' '+url.username+':'+url.password+'@'+url.hostname) i=p.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT],1) if i==0: print "I say yes" p.sendline('yes') i=p.expect([ssh_newkey,'password:',pexpect.EOF]) if i==1: #print "I give password", p.sendline(url.password) elif i==2: print "I either got key or connection timeout" pass elif i==3: #timeout pass p.sendline("\r") global global_pexpect_instance global_pexpect_instance = p signal.signal(signal.SIGWINCH, sigwinch_passthrough) try: p.interact() sys.exit(0) except: sys.exit(1) -- Esben Stien is b0ef@e s a http://www. s t n m irc://irc. b - i . e/%23contact sip:b0ef@ e e jid:b0ef@ n n