[newbie] trying socket as a replacement for nc

Jean Dubois jeandubois314 at gmail.com
Wed Dec 18 09:48:43 EST 2013


Op woensdag 18 december 2013 14:04:08 UTC+1 schreef Jean Dubois:
> Op dinsdag 17 december 2013 10:37:37 UTC+1 schreef Jean-Michel Pichavant:
> > > I'm a newbie in Python programming that is very much true, and
> > > contrary to what you seem to suggest I did my homework
> > At no point that was my intention, my apologies.
> OK, no problem
> > If you fixed the syntax error, you should be pretty close to the solution though.
> thanks, I'll look further into it when I find a bit more time
I finally got it working:
#!/usr/bin/env python
import telnetlib
host = '10.128.56.202'
port = 6000
t = telnetlib.Telnet(host, port)
t.read_very_eager() #flush
t.write('\n')
prompt = t.read_very_eager()
t.write('*IDN?\n')
print t.read_until('\n',5)

thanks to all here for the help offered

kind regards,
jean




More information about the Python-list mailing list