Created
May 8, 2014 02:52
-
-
Save erickmendonca/58d5d5e411979103eb20 to your computer and use it in GitHub Desktop.
Push IP through Pushbullet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import netifaces as ni | |
| import os | |
| ips = [] | |
| for interface in ni.interfaces(): | |
| if interface[0:3] == "eth" or interface[0:3] == "wla": | |
| try: | |
| ips.append(ni.ifaddresses(interface)[2][0]['addr']) | |
| except: | |
| pass | |
| print("My IP addresses:", ips) | |
| curl = "curl https://api.pushbullet.com/api/pushes \ | |
| -u YOUR-API-HERE: \ | |
| -d password=None \ | |
| -d device_iden=ujBV2b5q7P2djzWIEVDzOK \ | |
| -d type=link \ | |
| -d title=RaspberryIP \ | |
| -d url=MY_URL \ | |
| -X POST" | |
| for ip in ips: | |
| os.system(curl.replace("MY_URL", "http://"+ip)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll need the netifaces library installed. You can get that via pip.