telnet

How to open .txt file that contains ansi color codes

How to open .txt file that contains ansi color codes Question: In my telnet server written in python, if i send a message to client socket like this: socket.send(“33[32;1mHello!33[0m”) then it is correctly colorized for the client. But when i use a text file, for example, hello.txt with such content: 33[32;1mHello!33[0m and send it like …

Total answers: 1

What does "r" do in the following script?

What does "r" do in the following script? Question: I am using following script to reboot my router using Telnet: #!/usr/bin/env python import os import telnetlib from time import sleep host = "192.168.1.1" user = "USER" password = "PASSWORD" cmd = "system restart" tn = telnetlib.Telnet(host) sleep(1) tn.read_until("Login: ") tn.write(user + "nr") sleep(1) tn.read_until("Password: ") …

Total answers: 4

Python – inheriting from old-style classes

Python – inheriting from old-style classes Question: I am trying to connect via telnet to a laboratory instrument. I’d like to extend the Telnet class from the telnetlib module in the standard library, to include functions specific to our instrument: import telnetlib class Instrument(telnetlib.Telnet): def __init__(self, host=None, port=0, timeout=5): super(Instrument,self).__init__(host, port, timeout) All I am …

Total answers: 2

Python – telnet – automation APC PDU

Python – telnet – automation APC PDU Question: I am attempting to automation turning off connected devices to an APC PDU using python’s built in telnet functionality. I believe I am able to enter in the username and password, but I cannot proceed after that. My code is as follows: telnet_session = telnetlib.Telnet(host=self.apc_ip) self.logger.info(“Entering APC …

Total answers: 2