Pexpect support with Python3.2.3

G

Girish bist

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 [email protected] 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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top