Skip to content

Instantly share code, notes, and snippets.

@erickmendonca
Created May 8, 2014 02:52
Show Gist options
  • Select an option

  • Save erickmendonca/58d5d5e411979103eb20 to your computer and use it in GitHub Desktop.

Select an option

Save erickmendonca/58d5d5e411979103eb20 to your computer and use it in GitHub Desktop.
Push IP through Pushbullet
#!/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))
@erickmendonca
Copy link
Copy Markdown
Author

You'll need the netifaces library installed. You can get that via pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment