Hi -

I am using the pexpect version 2.4 with Python-3.2.3. I have written a
small script to verify the pexpect support with Python 3.2.3. This
script times out during the system call select execution. Can anyone
please help us with the issue here. The same script is working fine
with Python 2.7.3

thanks,

Script
=====
#!/usr/bin/python
import sys
import os

#print ("sys.path ****",sys.path)
import pexpect
import re
ssh_newkey = 'Are you sure you want to continue connecting'
# my ssh command line

p=pexpect.spawn('ssh galese@172.16.100.232 hostname')

i=p.expect([ssh_newkey,'(P|p)assword:',pexpect.EOF])
print ("i *********", i)
if i==0:
    print ("I say yes")
    p.sendline('yes')
    i=p.expect([ssh_newkey,'password:',pexpect.EOF]) # this expect
execution goes fine
    print ("**************",p.before,".") # print out the result
    print ("##############",p.after,".")
if i==1:
    print ("I give password")
    p.sendline("galese")
    i = p.expect([pexpect.EOF,pexpect.TIMEOUT]) # this expect
execution is timingout
    print ("i *********", i)
    print ("**************",p.before,".") # print out the result
    print ("##############",p.after,".")
elif i==2:
    print ("I either got key or connection timeout")
    pass
print ("**************",p.before,".") # print out the result
print ("##############",p.after,".")
print ("program complete")
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to