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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=0559fdd6f=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.084
X-Spam-Evidence '*H*': 0.83; '*S*': 0.00; 'subject:: [': 0.04; 'implements': 0.09; 'subject:trying': 0.09; 'python': 0.11; 'itself.': 0.14; "(it's": 0.16; 'eof,': 0.16; 'insights': 0.16; 'port)': 0.16; 'module': 0.19; 'dependent': 0.19; 'subject:] ': 0.20; 'import': 0.22; 'print': 0.22; 'install': 0.23; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'forgot': 0.30; 'code': 0.31; 'jean': 0.31; 'url:python': 0.33; 'to:name :python-list': 0.33; 'could': 0.34; 'installing': 0.36; 'url:org': 0.36; 'thank': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'equipment': 0.61; 'skip:t 30': 0.61; 'you.': 0.62; 'information': 0.63; 'kind': 0.63; 'such': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'apt-get': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.95,493,1384297200"; d="scan'208";a="2244742"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Mon, 16 Dec 2013 11:29:12 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Jean Dubois <jeandubois314@gmail.com>, python-list <python-list@python.org>
In-Reply-To <CAF=fzf-Q3g5TALXeN3Gkhc6baUXfG8GWyrLFveVOcX8iRn81-w@mail.gmail.com>
Subject Re: [newbie] trying socket as a replacement for nc
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC31 (Win)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4197.1387189761.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387189761 news.xs4all.nl 2870 [2001:888:2000:d::a6]:51421
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62039

Show key headers only | 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