[Tutor] Fwd: Re: I've subscribed to your service, no confirmation yet. I'm looking for a tutor and I need help with some code.

Alan Gauld alan.gauld at yahoo.co.uk
Wed May 25 12:19:19 EDT 2016


On 25/05/16 14:11, Angelia Spencer wrote:
> in your code below you're telnet-ing to a website,

No, I'm telnetting to a server with the IP address mysite.com
(which is obviously fictitious, but could be any valid IP address).
There is nothing that says it's a web site. (And even some web
sites might allow telnet access, that's just an admin thing)

> I am not and when I type, >>> response = tn.read(). I get an error.
>
> >>> response=tn.read()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: Telnet instance has no attribute 'read'
> >>>

Sorry, I misremembered the method name.
Here is an actual session using a public telnet site:

>>> import telnetlib
>>> tn = telnetlib.Telnet('telehack.com')
>>> response = tn.read_some()
>>>b'\r\nConnected to TELEH'
b'\r\nConnected to TELEH'
>>> tn.close()
>>>


There are a bunch of other read_xxxx() methods, you
need to read the help page to find out how they differ.
-- Alan G Author of the Learn to Program web site
http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow
my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos


More information about the Tutor mailing list