Last active
December 14, 2015 12:08
-
-
Save daegalus/5084535 to your computer and use it in GitHub Desktop.
Raspberry Pi Pong script. On boot, updates a central server with its current WAN and LAN ip so it can be booted headlessly on any network.
This file contains 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
import urllib2 | |
import commands | |
lanip = commands.getoutput('netstat -n -t | awk \'{print $4}\' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u') | |
wanip = urllib2.urlopen('http://ipv4.icanhazip.com').read().strip() | |
result = urllib2.urlopen('http://yulian.kuncheff.com/rpi/?ip='+lanip+'&lanip='+wanip,"").read() | |
if result != 'Ok': | |
sys.stderr.write('There was an errror posting IPs : '+result+'\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment