Config-File-Comp - Application#7 Config File...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
############# Application #7 - Config File Comparator ############# #This program will: # * Connect to a router via Telnet and it will compare the running-config file to the startup-config file on that device (this can be usually done with: show archive config differences) # * Compare a locally stored config file (.txt) with the running-config file or startup-config file running on a router. #Please see the "Python File Operations" section in the course for a recap of the necessary concepts. #Don't forget to configure Telnet access on the router! #username teopy privilege 15 password 0 python #line vty 0 4 # privilege level 15 # login local # transport input telnet ssh #The first part of the program is very similar to Application #2 in the course. import telnetlib import os.path import subprocess import time import sys def ip_validity(): global ip_address #Checking IP validity while True: ip_address = raw_input("Enter an IP address: ") #Checking octets a = ip_address.split('.') if (len(a) == 4) and (1 <= int(a[0]) <= 223) and (int(a[0]) != 127) and (int(a[0]) != 169 or int(a[1]) != 254) and (0 <= int(a[1]) <= 255 and 0 <= int(a[2]) <= 255 and 0 <= int(a[3]) <= 255): break else: print "\nThe IP address is INVALID! Please retry!\n" continue def file_validity(): while True: cfg_file = raw_input("Enter config file name and extension: ") #Changing exception message if os.path.isfile(cfg_file) == True: print "\nFile was found...\n" break else: print "\nFile %s does not exist! Please check and try again!\n" % cfg_file continue
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
def telnet(command): #Connecting to router via Telnet
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern