Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 15 lines (11 sloc) 421 Bytes
#!/usr/bin/python
import subprocess
def run_cmd(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
return (stdout, stderr, p.returncode)
def get_IP():
(stdout, stderr, returncode) = run_cmd(['hostname', '-i'])
if returncode != 0:
raise RuntimeError, "Failed to run hostname -i:\n" + stderr
return stdout.replace('\n', '')
Something went wrong with that request. Please try again.