Python Forum

Full Version: Telnet command in Python 3.9
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have Python 3.9.

When I trie to sent a command via Telnet to a device it doesn't react.

In Putty I'm able to sent the command, so that means the command itself and the device
and the connection work.

This is the code

from telnetlib import Telnet
import time
tn = Telnet('10.0.8.245', 23, 30)

time.sleep(1)

tn.write("SourceSelector1 set sourceSelection 1".encode('ascii') + b'\n')
I don't get any "errors". But I think it has something to do with ASCII and HEX and how the device reacts on that.

In Putty I just type in "plain text" , which I mean I just type letters on my keyboard.

Are there a few things I can try to see the outcome ?

Thanks for the help.