[Tutor] Telnet login

T. Girowall tgirowall at yahoo.com
Fri Nov 9 03:33:32 CET 2012


Hello All, 

I'm trying to telnet to a device with a particular IP address. I'm using the sample code below and get the following error: 
Erro 10061: "No connection could be made because the target machine actively refused it"

My firewall is turned off. 
I'm using Python 2.7
I'm using Windows XP

When I'm prompted for remote account, i enter the user name and then im prompted for the password which enter as well. 

I'm able to connect to the device using putty with following settings: 

ip: 192.168.xx.xx
port: 2332

Any help is appreciated, 
Tim
import getpass import sys import telnetlib HOST = "localhost" user = raw_input("Enter your remote account: ") password = getpass.getpass() tn = telnetlib.Telnet(HOST) tn.read_until("login: ") tn.write(user + "\n") if password: tn.read_until("Password: ") tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") print tn.read_all()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121108/cde85363/attachment.html>


More information about the Tutor mailing list