0
I'm using Python's socket module to get the server's IP address
server_ip = socket.gethostbyname(socket.getfqdn())
I get this error: socket.gaierror: [Errno -2] Name or service not known
Weird cause it works just fine on Fedora. Any ideas what's up?
Edit: The problem was the IP address could not be resolved to the hostname since it was not in /etc/hosts. Works fine now.
What's the rest of your code look like? Is a service already using the port you are trying to open? Run
netstat -an | egrep 'Proto|LISTEN'
to check – Bert – 2014-04-04T22:13:53.963No, a service isn't running on that port. I'm just trying to do the equivalent of
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
in Python without using subprocess. – Python Novice – 2014-04-05T02:31:56.610