from subprocess import getoutput def get_ip(): return getoutput("ifconfig | grep inet | grep -v 127.0.0.1 | grep -v inet6 | grep 'inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' -o | sed s/inet//g").strip()