[Ninux-Wireless] ifconfig vs ip addr

Giuseppe De Marco demarcog83 a gmail.com
Lun 25 Nov 2013 09:47:29 CET


import socket
socket.gethostbyname(socket.gethostname())


oppure fai un comando di sistema (subprocess.Popen), fetchi l'output,
e con le regexp di python trovi tutto.

Fai prima una findall eppoi un match con gruppi assegnati e ti ritrovi
un dizionario che puoi trasformare in oggetto o in cosa desideri
meglio.



2013/11/24 Nemesis <nemesis a ninux.org>

>  Ritorna la questione,
>
> guardate i commenti a questa domanda su stackoverflow:
>
> http://stackoverflow.com/questions/20177686/python-parser-for-unix-ip-address-command-iproute2
>
> In particolare questo commento:
>
> *"One more thing though: Your friends are totally right about iproute2
> being the future. But on many systems, particularly embedded ones, you're
> still more likely to encounter the good old ifconfig, the iproute2 package
> might not be installed. So if you want to make your abstraction layer
> portable, you'll probably have to account for both. – Lukas Graf"*
>
> Mi sa che tocca ingegnarsi di più.
>
> Federico
>
> _______________________________________________
> Wireless mailing list
> Wireless a ml.ninux.org
> http://ml.ninux.org/mailman/listinfo/wireless
>
>
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://ml.ninux.org/pipermail/wireless/attachments/20131125/fe60e5ce/attachment-0001.html>


Maggiori informazioni sulla lista Wireless