Created
August 19, 2014 01:59
-
-
Save mygeekdaddy/327ec9972579e0df8cda to your computer and use it in GitHub Desktop.
Python script to get current IP address
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
#!/usr/bin/env python | |
import sys, socket | |
def main(): | |
try: | |
# fqdn = socket.getfqdn() | |
ip_addr = socket.gethostbyname(socket.getfqdn()) | |
print ip_addr | |
return 0 | |
except Exception: | |
print 'No IP Addr' | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment