#!/usr/bin/python3
import os
import sys
import mechanize

os.system('ip route')
if sys.argv[2] != 'up':
	exit()

if os.environ.get('CONNECTION_ID') != 'Mavion_HOTSPOT':
	exit()

b = mechanize.Browser()
b.set_handle_robots(False)
b.set_debug_http(True)
b.open('http://10.5.50.1')
b.select_form(name="redirect")
b.submit()
b.follow_link(text_regex="Free Trial")
b.select_form(nr=0)
b.submit()
