Python Forum
Telnet command in Python 3.9
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Telnet command in Python 3.9
#1
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.
Larz60+ write Nov-12-2020, 01:09 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed this time. Please add tags on future posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  for loop script over telnet in Python 3.5 is not working abhijithd123 1 2,860 May-10-2020, 03:22 AM
Last Post: bowlofred
  Sending command using telnet mradovan1208 1 3,885 Apr-24-2020, 07:09 PM
Last Post: Larz60+
  Serial to telnet using Python Charles_Linquist 2 6,128 Jun-17-2019, 04:37 PM
Last Post: DeaD_EyE
  Multi thread telnet issue anna 0 2,099 Mar-29-2018, 05:35 PM
Last Post: anna
  telnet unexpected output printing anna 3 3,537 Jan-17-2018, 01:16 PM
Last Post: anna
  help required to parsing telnet output anna 8 8,462 Jan-12-2018, 11:05 AM
Last Post: anna
  telnet stuck when get Press any key to continue anna 2 4,702 Dec-31-2017, 11:34 AM
Last Post: anna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020