On Tue, Dec 17, 2013 at 5:26 AM, Jean Dubois <jeandubois...@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 -- https://mail.python.org/mailman/listinfo/python-list