You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if name == 'main':
main()
######### issue problem ###
Traceback (most recent call last):
File "ss.py", line 30, in
main()
File "ss.py", line 26, in main
child = connect(user,host,password)
File "ss.py", line 13, in connect
result = child.pexpect([pexpect.TIMEOUT, 'password:'])
AttributeError: 'spawn' object has no attribute 'pexpect'
any ideas ? thinks
The text was updated successfully, but these errors were encountered:
On 2 Jul 2018, at 12:51, yangxj99 ***@***.***> wrote:
centos 7.2
python 2.7
/usr/lib/python2.7/site-packages/pexpect
pexpect 4.6.0
test.py
#!/usr/bin/python
import pexpect
def send_comm(child, cmd):
child.sendline(cmd)
child.expect(Promt)
def connect(user, host, password):
connStr = 'ssh ' + user + '@' + host
child = pexpect.spawn(connStr)
result = child.pexpect([pexpect.TIMEOUT, 'password:'])
if result == 0:
print "[-] Error"
return
elif result == 1:
child.sendline(password)
child.expect(Promt)
return child
def main():
host = '192.168.xx.xx'
user = 'root'
password = '*************'
child = connect(user,host,password)
send_command(child, 'w')
if name == 'main':
main()
######### issue problem ###
Traceback (most recent call last):
File "ss.py", line 30, in
main()
File "ss.py", line 26, in main
child = connect(user,host,password)
File "ss.py", line 13, in connect
result = child.pexpect([pexpect.TIMEOUT, 'password:'])
AttributeError: 'spawn' object has no attribute 'pexpect'
any ideas ? thinks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
centos 7.2
python 2.7
/usr/lib/python2.7/site-packages/pexpect
pexpect 4.6.0
test.py
#!/usr/bin/python
import pexpect
def send_comm(child, cmd):
child.sendline(cmd)
child.expect(Promt)
def connect(user, host, password):
connStr = 'ssh ' + user + '@' + host
child = pexpect.spawn(connStr)
result = child.pexpect([pexpect.TIMEOUT, 'password:'])
if result == 0:
print "[-] Error"
return
elif result == 1:
child.sendline(password)
child.expect(Promt)
return child
def main():
host = '192.168.xx.xx'
user = 'root'
password = '*************'
child = connect(user,host,password)
send_command(child, 'w')
if name == 'main':
main()
######### issue problem ###
Traceback (most recent call last):
File "ss.py", line 30, in
main()
File "ss.py", line 26, in main
child = connect(user,host,password)
File "ss.py", line 13, in connect
result = child.pexpect([pexpect.TIMEOUT, 'password:'])
AttributeError: 'spawn' object has no attribute 'pexpect'
any ideas ? thinks
The text was updated successfully, but these errors were encountered: