Guest User

Untitled

a guest
Nov 24th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. def get_ui(login):
  2.     HOST = bras_ip
  3.     tn = telnetlib.Telnet(HOST)
  4.     tn.read_until("Username: ")
  5.     tn.write("superlogin\n")
  6.     tn.read_until("Password: ")
  7.     tn.write("superpass\n")
  8.     tn.read_until("bras2>")
  9.     tn.write("sh users | include %s \r" % login)
  10.     data =  tn.read_until("bras2>")
  11.     data.split()
  12.     Vi = data.split()[5]
  13.     try:
  14.         connect_type = data.split()[7]
  15.     except IndexError:
  16.         return "xuy"
  17.         sys.exit(0)
  18.     connect_time = data.split()[8]
  19.     ip_adr = data.split()[9]
  20.     tn.write("sh pppoe session | include %s \r" % Vi)
  21.     data2 = tn.read_until("bras2>")
  22.     data2.split()
  23.     mac_adr = data2.split()[8]
  24.     vlan = data2.split()[9]
  25.     tn.write("exit\n")
  26.     tn.close();
  27.     return Vi, connect_type, connect_time, ip_adr, mac_adr, vlan
Add Comment
Please, Sign In to add comment