aramideoluwatosin

week2question1.py

Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. from pprint import pprint
  5.  
  6.  
  7. f=open('show_version.txt')
  8. output=f.read()
  9.  
  10.  
  11. print (output)
  12. print (type(output))
  13.  
  14.  
  15. f.close()
  16. with open('show_version.txt') as w:
  17. outputw=w.readlines()
  18. print (outputw)
  19. print (type(outputw))
  20.  
  21.  
  22. print('-'*40)
  23.  
  24.  
  25.  
  26. my_ipaddress = ['192.168.1.1', '10.1.1.1', '172.16.31.254', '8.8.8.8', '8.8.4.4']
  27. my_ipaddress.append('54.1.1.1')
  28.  
  29. print(my_ipaddress)
  30. print('-'*40)
  31. my_ipaddress.extend(['1.1.1.1', '1.1.1.2'])
  32. print(my_ipaddress)
  33. print('-'*40)
  34. print (my_ipaddress + ['172.16.1.1', '172.16.1.2'])
  35. print('-'*40)
  36. print('The entire ip addresses are: '+ str(my_ipaddress + ['172.16.1.1', '172.16.1.2']))
  37.  
  38. print('-'*40)
  39. print('The FIRST ip address is: '+ str((my_ipaddress + ['172.16.1.1', '172.16.1.2'])[0]))
  40. print('-'*40)
  41. print('The last ip address is: '+ str((my_ipaddress + ['172.16.1.1', '172.16.1.2'])[-1]))
  42. print('-'*40)
  43. my_ipaddress.pop(-1)
  44. my_ipaddress.pop(0)
  45. my_ipaddress[0]='2.2.2.2'
  46. print('The FIRST ip address is: '+ str((my_ipaddress + ['172.16.1.1', '172.16.1.2'])[0]))
  47. print('The entire ip addresses are: '+ str(my_ipaddress + ['172.16.1.1', '172.16.1.2']))
  48.  
  49.  
  50.  
  51. print('0'*40)
  52. with open('show_arp.txt') as k:
  53. output_k=k.readlines()
  54. print (output_k)
  55. print('0'*40)
  56. output_k=output_k[1:]
  57. pprint(output_k)
  58.  
  59. output_k.sort()
  60. arp_entries=output_k[:3]
  61. arp_entries='\n'.join(arp_entries)
  62.  
  63. with open("arp.txt", "wt") as k:
  64. k.write(arp_entries)
  65.  
  66.  
  67. print('*'*40)
  68. with open('show_ip_int_brief.txt') as z:
  69. output_z=z.readlines()
  70. FastEthernet4_split = output_z[-2].split()[1]
  71. FastEthernet4_split_interface= output_z[-2].split()[0]
  72.  
  73. my_results=(FastEthernet4_split_interface, FastEthernet4_split)
  74. print(FastEthernet4_split_interface +' : '+FastEthernet4_split)
  75. print('{}: {}'.format(FastEthernet4_split_interface,FastEthernet4_split))
  76. print(my_results)
  77.  
  78.  
  79.  
  80. print('*'*40)
  81. with open('show_ip_bgp_summ.txt') as n:
  82. output_n=n.readlines()
  83. first_line=output_n[0].split()[-1]
  84. last_line=output_n[-1].split()[0]
  85. print('The local AS number: {}'.format(first_line))
  86. print('BGP peer IP address: {}'.format(last_line))
Advertisement
Add Comment
Please, Sign In to add comment