Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Technicolor telnetlib example
#!/usr/bin/env python
#
import telnetlib
import sys
max_wait = 2
prompt = "=>"
tn = telnetlib.Telnet("192.168.1.254","23")
tn.read_until("Username : ", max_wait)
tn.write("admin\r\n")
tn.read_until("Password : ", max_wait)
tn.write("password\r\n")
def wifi_enable():
tn.read_until("prompt", max_wait)
tn.write(":wireless radio state=enabled\r\n")
def wifi_disable():
tn.read_until("prompt", max_wait)
tn.write(":wireless radio state=disabled\r\n")
def save_exit():
tn.read_until("prompt", max_wait)
tn.write(":saveall\r\n")
tn.read_until("prompt", max_wait)
tn.write(":exit\r\n")
if __name__ == '__main__':
wifi_disable()
#wifi_enable()
save_exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.