-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbbp1.0.py
29 lines (24 loc) · 841 Bytes
/
bbp1.0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
osname = subprocess.check_output(['uname'])
user_name = subprocess.check_output(['whoami'])
if osname == 'Linux' or 'Unix':
ip_add_info = subprocess.check_output(['ifconfig']).decode('utf-8')
ip_add=ip_add_info.split('\n')
for i in ip_add:
if '' == i:
ip_add.remove(i)
std_ip_add=[]
a=[]
for i in ip_add:
std_ip_add.append(i.split(' '))
a = std_ip_add[9]
for i in a:
if '' == i:
a.remove(i)
gateway_info = subprocess.check_output(['ip','route']).decode('utf-8')
gateway_info=gateway_info.split(' ')
gateway=gateway_info[75]
print("OS name: {}".format(osname.decode('utf-8')))
print("User name: {}".format(user_name.decode('utf-8')))
print("User IP: {}".format(a[3]))
print("Router IP: {}".format(gateway))