Re: Getting fully qualified name

Samuel Tardieu (tardieu@inf.enst.fr)
Sat, 3 Sep 1994 12:00:20 +0200

> Sam wrote:
>
> >I need to get the full qualified name of the host on which a Python
> program
> >is running. How can I get it ? gethostname() returns 'khamsin' instead
> >of 'khamsin.enst.fr' (yeah, I'm on a Sun :( )
> >
> > Sam
>
> I'm afraid that the problem comes from your environment, as
sys.gethostname()
> is merely an interface to the gethostname() system call.
> And as I tried it on my machine (also Sun4), I got tamsun.tamu.edu
> So I don't think the solution is given by Python.

Yep, but I miss the gethostbyaddr function, to be able to do something
like:

from socket import *

def getfullhostname():
return gethostbyaddr(gethostbyname(gethostname()))

Sam

--
Samuel Tardieu - sam@enst.fr