Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- error = "Aucune IP disponible"
- try:
- ip = str(subprocess.check_output("ifconfig wlan0|grep inet", shell=True))
- except:
- ip = error
- count = ip.count(":")
- if count == 3:
- ip = ip.split(":")
- ip = ip[1].split(" ")
- ip = ip[0]
- else:
- try:
- ip = str(subprocess.check_output("ifconfig eth0|grep inet", shell=True))
- except:
- ip = error
- count = ip.count(":")
- if count == 3:
- ip = ip.split(":")
- ip = ip[1].split(" ")
- ip = ip[0]
- else:
- ip = error
- print(ip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement