Hi,
I have written a small code to connect to solaris machine from cygwin...but this code is giving some error. please see the code below..i am expect some solution of this error.. Thanks in advance
import os, pexpect, time
FirstTime_Ssh='Are you sure you want to continue connecting (yes/no)?'
def ConnectUnix():
connect=pexpect.spawn('ssh sanju@hostname')
#time.sleep(20)
i=connect.expect([FirstTime_Ssh,'.*password:',pexpect.EOF],timeout=100)
print i
if i==0:
print "yes"
connect.sendline('yes')
i=connect.expect([FirstTime_Ssh,'.*password:',pexpect.EOF],timeout=100)
elif i==1:
print "give the password"
time.sleep(20)
connect.sendline('sanju')
time.sleep(20)
print connect.expect(pexpect.EOF,timeout=120)
elif i==2:
print "got the key or connection timeout"
pass
print connect.before
ConnectUnix()
This is the error section:
1
give the password
Traceback (most recent call last):
File "connect.py", line 29, in <module>
ConnectUnix()
File "connect.py", line 22, in ConnectUnix
print connect.expect(pexpect.EOF,timeout=120)
File "pexpect.py", line 1311, in expect
return self.expect_list(compiled_pattern_list, timeout, sea
File "pexpect.py", line 1325, in expect_list
return self.expect_loop(searcher_re(pattern_list), timeout,
)
File "pexpect.py", line 1409, in expect_loop
raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
<pexpect.spawn object at 0x7ff2a0cc>
version: 2.3 ($Revision: 399 $)
command: /usr/bin/ssh
args:
searcher: searcher_re:
0: EOF
buffer (last 100 chars): Generic January 2005
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
hostname%
before (last 100 chars): Generic January 2005
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
hostname%
after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 4604
child_fd: 3
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1