@@ -0,0 +1,1435 @@
+%0A#!/usr/bin/env python%0A%0A'''%0AParse the below 'show version' data and obtain the following items (vendor, %0Amodel, os_version, uptime, and serial_number).  Try to make your string parsing%0Ageneric i.e. it would work for other Cisco IOS devices. %0AThe following are reasonable strings to look for:%0A'Cisco IOS Software' for vendor and os_version%0A'bytes of memory' for model%0A'Processor board ID' for serial_number%0A' uptime is ' for uptime%0AStore these variables (vendor, model, os_version, uptime, and serial_number) in %0Aa dictionary.  Print the dictionary to standard output when done.%0ANote, %22Cisco IOS Software...Version 15.0(1)M4...(fc1)%22 is one line.%0A%0Afile with sh ver is ex4_2.txt%0A'''%0A%0A%0Afrom sys import argv%0A%0Afilename = argv%5B1%5D%0A%0Ash_ver = open(filename).read()%0A%0Ash_ver_lines = sh_ver.split('%5Cn')%0A%0Aresult_lines = %5B%5D%0A%0Afor line in sh_ver_lines:%0A  if line.find('Cisco IOS Software') != -1: line1 = line.split(', ')%0A  if line.find('bytes of memory') != -1: line2 = line.split('(')%0A  if line.find('Processor board ID') != -1: line3 = line.split()%0A  if line.find('uptime is') != -1: line4 = line.split('is ')%0A%0Aresult_dic = %7B%7D%0A %0Aresult_dic%5B'vendor'%5D = line1%5B0%5D.split()%5B0%5D%0Aresult_dic%5B'os_version'%5D = line1%5B2%5D.split()%5B1%5D%0Aresult_dic%5B'model'%5D = line2%5B0%5D.split()%5B1%5D%0Aresult_dic%5B'serial_number'%5D = line3%5B3%5D%0Aresult_dic%5B'uptime'%5D = line4%5B1%5D%0A%0Aprint %22=%22 * 60%0Afor key in result_dic.keys():%0A  print %22%25-15s%25-45s%22 %25 (key, result_dic%5Bkey%5D)%0Aprint %22=%22 * 60%0Aprint %22%22%0A

Create ex4_2.py