I need to establish a connection to a telnet server which continually broadcasts information and save all of that information to a file. For testing, I am using the famous ASCII Star Wars located on towel.blinkenlights.nl
In essence, I need to replicate in Python what you get when inputting the following command into Windows Command Prompt: telnet towel.blinkenlights.nl /f c:/randfolder/output.txt
The below does establish the connection and is showing the data received in terminal, however I am having no luck in saving what I see in the terminal to a file:
import telnetlib
HOST = "towel.blinkenlights.nl"
PORT = "23"
telnetObj=telnetlib.Telnet(HOST,PORT)
outF = open("output.txt", "a")
outF.write(telnetObj.interact())
telnetObj.close()