| | |
Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
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
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
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.
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.
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:
As you can see from the pexpect failure, the last 100 characters of output from your command were the following:
Python Syntax (Toggle Plain Text)
buffer (last 100 chars): Generic January 2005 Sun Microsystems Inc. SunOS 5.10 Generic January 2005 hostname%
Last edited by jlm699; Jul 15th, 2009 at 4:32 pm.
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
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..
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..
Re: Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()."
0
#5 Jul 22nd, 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..
![]() |
Similar Threads
- Error: "Use of undefined constant" Help! (PHP)
- error showin "no data found" (JSP)
- Submit error (PHP)
- "critical system error" + HJT log (Viruses, Spyware and other Nasties)
- (Help Please) - Config Error: "Login failed for user 'STS-SYNMAC\userName (C#)
- Error: "couldn't fetch mysqli ..." (PHP)
- Sometimes an error come out "Could not connect to database".Why?? (Oracle)
- ABIT IC7 G "CMOS Checksum error" and "CPU has been changed or is unworkable" (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: What am I doing wrong?
- Next Thread: Creating and playing a sine wave sound (Python)
| Thread Tools | Search this Thread |
alarm assignment avogadro beginner bluetooth character cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples excel exe file float font format function generator gnu graphics gui halp homework http ideas import input itunes java leftmouse line linux list lists logging loop maintain maze module mouse number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh stdout string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 variable ventrilo verify vigenere web webservice wikipedia windows wxpython xlib






