Created
January 24, 2015 20:02
-
-
Save sokratisg/41caafc4b48cd6f9bd90 to your computer and use it in GitHub Desktop.
Technicolor telnetlib example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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