Permalink
Browse files

Easily print out machine's IP

  • Loading branch information...
1 parent c326e4f commit 48654f51524a81bebe1df9c7d8546b0d59ac1c68 @andrewn committed Jul 26, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 print-ip.py
View
@@ -0,0 +1,19 @@
+import serial
+import commands
+import re
+
+def getIp():
+ ifconfig = commands.getoutput('ifconfig')
+ matches = re.search('ddr:(.*?) ', ifconfig)
+ print 'matches'
+ if len(matches.groups()) > 0:
+ return matches.group(1)
+ else:
+ return None
+
+ser = serial.Serial('/dev/ttyAMA0', 19200)
+while(getIp() == None):
+ pass
+
+ser.write(getIp())
+ser.flush()

0 comments on commit 48654f5

Please sign in to comment.