Script which will telnet to a switch and create a new VLAN:
import getpass
import sys
import telnetlib
HOST = ‘192.168.1.1’
user = raw_input(‘Enter your telnet username: ‘)
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until(‘Login: ‘)
tn.write(user + ‘\n’)
if password:
tn.read_until(‘Password: ‘)
tn.write(password + ‘\n’)
tn.write(‘enable\n’)
tn.write(‘conf t\n’)
tn.write(‘vlan create 101 type port-mstprstp 0\n’)
tn.write(‘exit\n’)
tn.write(‘exit\n’)