[newbie] trying socket as a replacement for nc

Jean Dubois jeandubois314 at gmail.com
Mon Dec 16 13:26:14 EST 2013


Op maandag 16 december 2013 17:44:31 UTC+1 schreef Jean-Michel Pichavant:
> > This is what I got using telnet:
> > [jean:~] $ telnet 10.128.59.63 7000
> > Trying 10.128.59.63...
> > Connected to 10.128.59.63.
> > Escape character is '^]'.
> > *IDN?
> > KEITHLEY INSTRUMENTS INC.,MODEL 2425,1078209,C32   Oct  4 2010
> > 14:20:11/A02  /E/
> >                                                                  H
> > 
> > after pressing CTRL-ALT-ALTGR-] I get this:
> > ^[^]
> > after which I get the telnet-prompt
> > >telnet
> > and I can quit telnet by entering quit
> > 
> > 
> > kind regards,
> > jean
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> Looks like you don't have any prompt.
> 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 at mantec:~$ ./test.py 
  File "./test.py", line 7
    def flush()
              ^
SyntaxError: invalid syntax


Tried it both with python2 and python3, same error...

kind regards,
jean



More information about the Python-list mailing list