Skip to content

Instantly share code, notes, and snippets.

@sokratisg
Created January 24, 2015 20:02
Show Gist options
  • Save sokratisg/41caafc4b48cd6f9bd90 to your computer and use it in GitHub Desktop.
Save sokratisg/41caafc4b48cd6f9bd90 to your computer and use it in GitHub Desktop.
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