Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62089
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'subject:: [': 0.04; 'syntax': 0.04; 'interpreter.': 0.07; 'subject:trying': 0.09; 'variant': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'expert.': 0.16; 'first:': 0.16; 'folks,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'fully,': 0.16; 'port)': 0.16; 'success:': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'written': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'host': 0.29; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'jean': 0.31; 'file': 0.32; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'simple': 0.61; 'invalid': 0.68; 'to:none': 0.92; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=mcd7Iy1skUTICj08kCPO5DV7ytwW7tgXuhXS+HxQ/RE=; b=A0fFs0WvC8gPgsPIIc6un+4qE4jS7snBoxlj6T7xGJQU+tq8dAAGxCWgA65RvOmqRX F5ZRoALyB9OzyJwcjfMyuzJTuTQOv5xR4D/DwxP3bfbAt6M1wPhJdeJdNLcmCyhUJi+1 0pvV+eGteuK1m3zZL4kuKwj9gZuNSu2uchMwuOL6w73KkqVtvN5S+eVQAUV9oGCk0eFC gkGfRgJ75ZZuxYTIELl46rcZFPt+7ATclA+z4Y0FZ9VFUoL2Wdoc8+wu9XWafUOZ1UEB sd3Ji6USJ31I7W8nhnUmQELwse9mUlLaIEA71ODWeK5arPWGxaJpkg1ckf11V5UnJf53 yqYQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.66.234 with SMTP id i10mr21753269pat.127.1387218958182; Mon, 16 Dec 2013 10:35:58 -0800 (PST) |
| In-Reply-To | <a71c4874-2fbc-439d-bc2a-483feb4f3080@googlegroups.com> |
| References | <41954a05-c9bd-43f7-9427-915653ff8657@googlegroups.com> <mailman.4222.1387212273.18130.python-list@python.org> <a71c4874-2fbc-439d-bc2a-483feb4f3080@googlegroups.com> |
| Date | Tue, 17 Dec 2013 05:35:57 +1100 |
| Subject | Re: [newbie] trying socket as a replacement for nc |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.4228.1387218961.18130.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387218961 news.xs4all.nl 2968 [2001:888:2000:d::a6]:37731 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62089 |
Show key headers only | View raw
On Tue, Dec 17, 2013 at 5:26 AM, Jean Dubois <jeandubois314@gmail.com> wrote:
>> Try something simple first:
>> import telnetlib
>> host = '10.128.59.63'
>> port = 7000
>> t = Telnet(host, port)
>> def flush()
>> t.read_very_eager()
>> def sendCmd(cmd)
>> t.write('%s\n' % cmd)
>> return flush()
>> flush()
>> print sendCmd('*IDN?')
>> print sendCmd('*OPC?')
> Still no success:
> jean@mantec:~$ ./test.py
> File "./test.py", line 7
> def flush()
> ^
> SyntaxError: invalid syntax
>
>
> Tried it both with python2 and python3, same error...
Folks, the OP isn't an expert. Please test your scripts before posting!
I don't have everything I need to test this fully, but here's a
variant of the above that's at least syntactically correct:
from telnetlib import *
host = '10.128.59.63'
port = 7000
t = Telnet(host, port)
def flush():
t.read_very_eager()
def sendCmd(cmd):
t.write('%s\n' % cmd)
return flush()
flush()
print sendCmd('*IDN?')
print sendCmd('*OPC?')
It's written for Python 2, so use that interpreter.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [newbie] trying socket as a replacement for nc Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-12-16 17:44 +0100
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-16 10:26 -0800
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-17 05:35 +1100
Re: [newbie] trying socket as a replacement for nc Dave Angel <davea@davea.name> - 2013-12-16 13:42 -0500
csiph-web