Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62039

Re: [newbie] trying socket as a replacement for nc

Date 2013-12-16 11:29 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: [newbie] trying socket as a replacement for nc
Newsgroups comp.lang.python
Message-ID <mailman.4197.1387189761.18130.python-list@python.org> (permalink)

Show all headers | View raw


> > Such equipment often implements a telnet protocol. Have use try
> > using the telnetlib module ?
> > http://docs.python.org/2/library/telnetlib.html
> >
> > t = Telnet(host, port)
> > t.write('*IDN?')
> > print t.read_until('Whateverprompt')
> > # you can use read_very_eager also
> >
> > JM
> >
> >
> Could you tell me how to install telnetlib on a linux-system (it's
> not
> available via apt-get install as I see it)
> 
> kind regards,
> jean
> 

Please keep it on list, some other may have the same install issue or someone could have better insights on installing telnetlib.

telnetlib is part of the standard modules in my Debian squeeze(python 2.5). Looking at the doc, it looks like it's available for python 3 as well. Strange that you don't have it.

Did you try

import telnetlib

?

Note that in the code above I forgot the EOF, which is very much dependent of the equipment itself.

You may have to write
t.write('*IDN?\n')
or
t.write('IDN?\n\r')

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [newbie] trying socket as a replacement for nc Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-12-16 11:29 +0100
  Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-16 03:44 -0800

csiph-web