Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Enable SNMP on Canopy device
# Set SNMP accessibility on Canopy device
# 2012 Jon Auer <>
import sys
import urllib, urllib2
def enablewrite(dev):
# get first page
first = urllib2.urlopen(url="http://%s" % dev).read()
# extract mac
mac = None
for l in first.split():
if "URL=" in l:
l = l.replace("'", '')
mac = l.split('=')[2]
if not mac:
raise Exception('Could not find MAC address')
# do change
payload = urllib.urlencode({
'1092:SNMPReadOnly': 0,
'ok': 'Save Changes',
'mac_esn': mac,
'catindex': 1,
'pageindex': 6})
post = urllib2.urlopen(url="http://%s/himom.cgi" % (dev), data=payload).read()
if __name__ == "__main__":
if len(sys.argv) != 2:
print "Usage: %s DEVADDR" % (sys.argv[0])
if enablewrite(sys.argv[1]):
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.