Telnet Python

Script which will telnet to a switch and create a new VLAN:

import getpass
import sys
import telnetlib

HOST = ‘’
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(‘conf t\n’)
tn.write(‘vlan create 101 type port-mstprstp 0\n’)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s