['ifconfig'] ['>ifconfig'] ['br0 Link encap', 'Ethernet HWaddr A4:33:D7:53:5E:08 '] [' inet addr', '192.168.15.1 Bcast:192.168.15.255 Mask:255.255.255.0'] [' inet6 addr', ' 2804:431:c7c7:6528:a633:d7ff:fe53:5e08/64 Scope:Global'] [' inet6 addr', ' fe80::a633:d7ff:fe53:5e08/64 Scope:Link'] [' UP BROADCAST RUNNING ALLMULTI MULTICAST MTU', '1500 Metric:1'] [' RX packets', '6563071 errors:0 dropped:0 overruns:0 frame:0'] [' TX packets', '7874170 errors:0 dropped:0 overruns:0 carrier:0'] [' collisions', '0 txqueuelen:0 '] [' RX bytes', '714777540 (681.6 MiB) TX bytes:886124155 (845.0 MiB)'] [''] ['br0', '0 Link encap:Ethernet HWaddr A4:33:D7:53:5E:08 '] [' inet addr', '192.168.249.1 Bcast:192.168.249.3 Mask:255.255.255.252'] [' UP BROADCAST RUNNING ALLMULTI MULTICAST MTU', '1500 Metric:1']
['ifconfig']
['>ifconfig']
['br0 Link encap', 'Ethernet HWaddr A4:33:D7:53:5E:08 ']
[' inet addr', '192.168.15.1 Bcast:192.168.15.255 Mask:255.255.255.0']
[' inet6 addr', ' 2804:431:c7c7:6528:a633:d7ff:fe53:5e08/64 Scope:Global']
[' inet6 addr', ' fe80::a633:d7ff:fe53:5e08/64 Scope:Link']
[' UP BROADCAST RUNNING ALLMULTI MULTICAST MTU', '1500 Metric:1']
[' RX packets', '6563071 errors:0 dropped:0 overruns:0 frame:0']
[' TX packets', '7874170 errors:0 dropped:0 overruns:0 carrier:0']
[' collisions', '0 txqueuelen:0 ']
[' RX bytes', '714777540 (681.6 MiB) TX bytes:886124155 (845.0 MiB)']
['']
['br0', '0 Link encap:Ethernet HWaddr A4:33:D7:53:5E:08 ']
[' inet addr', '192.168.249.1 Bcast:192.168.249.3 Mask:255.255.255.252']
[' UP BROADCAST RUNNING ALLMULTI MULTICAST MTU', '1500 Metric:1']
Fiz assim, porém não estãestá funcionando:
for chave in saida: #print(chave) aux = chave.split(":",1) print(aux) if aux[0] == 'br0 Link encap': saida_json['MAC'] = aux[1].strip() elif aux[0] == ' inet6 addr': saida_json['IPV6'] = aux[1].strip()
for chave in saida:
#print(chave)
aux = chave.split(":",1)
print(aux)
if aux[0] == 'br0 Link encap':
saida_json['MAC'] = aux[1].strip()
elif aux[0] == ' inet6 addr':
saida_json['IPV6'] = aux[1].strip()