Administrator Guide

15 Python Scripting for Dell Networking N-Series | Version 1.0.1
tn.write(TERMINAL_MONITOR)
tn.read_until("#")
tn.write(TERMINAL_LEN_ZERO)
tn.read_until("#")
def do_login(tn):
tn.read_until(LOGIN_STRING, TIMEOUT)
tn.write(USERNAME + "\n")
tn.read_until(PASSWORD_STRING, TIMEOUT)
tn.write(PASSWORD + "\n")
tn.read_until(">", TIMEOUT)
tn.write(ENABLE_STRING)
tn.read_until("#", TIMEOUT)
#Replace the “xx.xx.xx.xx” below with the TFTP server IP address
def do_config(tn):
tn.read_until("#", TIMEOUT)
tn.write("copy running-config tftp
://xx.xx.xx.xx/running-configuration\n");
tn.read_until("(y/n)", TIMEOUT)
tn.write("y");
tn.read_until("#", TIMEOUT)
def main():
telnet = telnetlib.Telnet(HOST,PORT)
do_login(telnet)
do_terminal_settings(telnet)
do_config(telnet)
telnet.close()
sys.exit(0)
main()
Switch commands
Enter the following commands from the switch command line, replacing xx.xx.xx.xx with the TFTP servers IP
address. Replace <filename1> with the name of the compressed file. Replace <filename2> with the name of
the decompressed file (which automatically unzips during the copy):
console#copy tftp
://xx.xx.xx.xx/<filename1> application <filename1>
console#configure
console(config)#application install <filename2> start-on-boot
console(config)#exit
console#write
The last command, write, copies the running configuration to the startup configuration. The running
configuration must be saved to the startup configuration for the start-on-boot feature to work. The script will
run the next time the switch boots and every time thereafter. There are several ways a script can terminate,
most of which are listed in Section 1.4, Python script flow on Dell N-Series
.