[newbie] trying socket as a replacement for nc

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Dec 16 05:29:12 EST 2013


> > 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.


More information about the Python-list mailing list