I'm trying to telnet from Linux to Windows PC but it's showing error "login failed".
Here is my Python script. I am using pexpect
module. I also tried with telnetlib
but same error:
import os
import pexpect,time
telconn = pexpect.spawn('telnet 192.168.0.105')
telconn.logfile = open("/tmp/telnetlog", "a")
time.sleep(30)
print "connected"
telconn.expect(':')
telconn.sendline("user" + "\r")
#time.sleep(10)
print "connected user"
telconn.expect(':')
password = "user@123"
#print password
telconn.sendline(password + "\r")
time.sleep(60)
#print "connected password"
Error :
Connected to 192.168.0.105.
Escape character is '^]'.
Welcome to Microsoft Telnet Service
login: user
password: user@123
The operation completed successfully.
Login Failed
@vish You can debug the problem using wireshark according to Marcin.You just try below mentioned code as i already had the same problem and i got the solution
import pexpect
import time,sys
telconn = pexpect.spawn('telnet 192.168.0.105')
time.sleep(20)
telconn.logfile = sys.stdout
telconn.expect(":")
time.sleep(20)
telconn.send("user" + "\r")
telconn.expect(":")
telconn.send("user@123" + "\r")
telconn.send("\r\n")
time.sleep(20)
telconn.expect(">")
I hope this will work.