I’m trying to send Telnet commands to a device over ethernet connection to a Lantronix device (XPORT AR – XP3002000-01R). I’ve tried to use the socket library for python but it doesn’t seem to be responding.
The Lantronix device required an Enable and Connect Line 1 enter image description here before taking other commands
I am using this code to try and connect and send the ENABLE command a receive the (enable)# response but the response that is being printed is “received data: b’xffxfbx03′”
`
#!/usr/bin/env python
import socket
TCP_IP = '10.1.5.4'
TCP_PORT = 23
BUFFER_SIZE = 1024
MESSAGE = bytes("ENABLE"+"n", 'ansi')
LINE_CONNECT = bytes("CONNECT LINE 1""n",'ansi')
TEST = bytes("EXE_TEST1""n",'ansi')
#MESSAGE = bytes("*IDN?",'ansi')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE).decode('utf8')
#s.close()
print("received data:", data)
s.send(LINE_CONNECT)
data = s.recv(BUFFER_SIZE)
print("received data:", data)
s.send(TEST)
s.close
### end of script`
Gareth Tanner is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.