Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 2
Reputation: sanju.d1231 is an unknown quantity at this point 
Solved Threads: 0
sanju.d1231 sanju.d1231 is offline Offline
Newbie Poster

Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

 
0
  #1
Jul 15th, 2009
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: ['/usr/bin/ssh', 'sanju@hostname']
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

 
0
  #2
Jul 15th, 2009
Read this
http://www.daniweb.com/forums/announcement114-3.html

Then put some code tags around your actual code.
Python scope rules rely on indentation, and your post without any is broken beyond help.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,057
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 266
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

 
0
  #3
Jul 15th, 2009
All I can tell is that your expect strings never get found. So you would be better to figure out how to do this on the command line, and then replicate those actions using pexpect (since pexpect basically spoofs you performing the same commands (sendline) and waiting for certain responses (expect))

As you can see from the pexpect failure, the last 100 characters of output from your command were the following:
  1. buffer (last 100 chars): Generic January 2005
  2. Sun Microsystems Inc. SunOS 5.10 Generic January 2005
  3. hostname%
Last edited by jlm699; Jul 15th, 2009 at 4:32 pm.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 2
Reputation: sanju.d1231 is an unknown quantity at this point 
Solved Threads: 0
sanju.d1231 sanju.d1231 is offline Offline
Newbie Poster

Re: Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

 
0
  #4
Jul 16th, 2009
Thanks a lot Jim for your comments.

jim My expect string gets found, because of you see the i, its value is 1 which means expect string is able to found the .*password string..

problem starts when i send the password from the sendline..
after sendline its not sending any response.

I don;t know why it is happening because ideally it should return some thing..
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,057
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 266
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."

 
0
  #5
Jul 22nd, 2009
Originally Posted by sanju.d1231 View Post
Thanks a lot Jim for your comments.

jim My expect string gets found, because of you see the i, its value is 1 which means expect string is able to found the .*password string..

problem starts when i send the password from the sendline..
after sendline its not sending any response.

I don;t know why it is happening because ideally it should return some thing..
When you send your password do you hit 'Enter' ? Add \n after your password to see if that helps.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC