[Tutor] Python -> uname -n
dyoo at hkn.eecs.berkeley.edu
Tue Sep 14 00:19:36 CEST 2004
On Mon, 13 Sep 2004, Tim Johnson wrote:
> > How may I obtain the network node hostname with python?
> > On linux, it would be the value returned by 'uname -n'
> Found it all by my lonesome, under Python Library Reference, the
> 'commands' module.
> commands.getstatusoutput('uname -n') returns a 2 - member tuple with
> status code as the first item and response string as second item.
You might be able to get it with 'socket.gethostname()' as well:
>>> import socket
for more details on socket.gethostname().
More information about the Tutor