i have issue while running telnet script using pexpect.problem taking username script not password.its taking value of password not entering same.mentioned below script,
import pexpect import sys,time ipaddr = "192.168.100.85" username = "usr" password = "pass@123" telconn = pexpect.spawn("telnet " + ipaddr) telconn.expect(":") telconn.logfile=sys.stdout time.sleep(15) telconn.sendline(username + "\r") telconn.expect(":") telconn.sendline(password + "\r") time.sleep(30) telconn.expect(">") print "authentication sucesss"
output of this,
trying 192.168.100.85... connected 192.168.100.85. escape character '^]'. welcome microsoft telnet service login: usr password: pass@123 operation completed successfully. login failed
i got solution this,
import pexpect import time,sys telconn = pexpect.spawn('telnet 192.168.100.85') time.sleep(20) telconn.logfile = sys.stdout telconn.expect(":") time.sleep(20) telconn.send("usr" + "\r") telconn.expect(":") telconn.send("pass@123" + "\r") telconn.send("\r\n") time.sleep(20) telconn.expect(">")
this worked me
Comments
Post a Comment