Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. from exempelkodhtmltabell import thomas
  2.  
  3.  
  4. def router_config():
  5. router = open('C:\\Users\\felic\\Desktop\\Lab3\\router_configuration.txt')
  6. printRouter = router.readlines()
  7. lcc = 'Last configuration change'
  8. hostName = "hostname"
  9. ip = 'ip address'
  10. noip = 'no ip address'
  11. for sLine in printRouter:
  12. if ip in sLine and not noip in sLine:
  13. print(sLine[11:])
  14. ip_a = sLine[11:]
  15. if hostName in sLine:
  16. print(sLine[8:15])
  17. hn = sLine[8:15]
  18. if lcc in sLine:
  19. print(sLine[30:])
  20. cc = sLine[30:]
  21.  
  22. return cc, hn, ip_a
  23.  
  24. def router_version():
  25. version = open('C:\\Users\\felic\\Desktop\\Lab3\\router_show_version.txt')
  26. printVersion = version.readlines()
  27.  
  28. # ger strängarna som vi ska plocka från filen ett variabel namn
  29. rom = 'ROM: System'
  30. time = 'uptime'
  31. for sLine in printVersion:
  32. if rom in sLine:
  33. print(sLine[23:])
  34. rom_a = sLine[23:]
  35. if time in sLine:
  36. print(sLine[15:])
  37. tid = sLine[15:]
  38.  
  39. return rom_a, tid
  40.  
  41.  
  42. cc, hn, ip_a = router_config()
  43. rom_a, tid = router_version()
  44. thomas(cc, hn, ip_a,rom_a, tid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement