[Tutor] Python -> uname -n

Tim Johnson tim at johnsons-web.com
Tue Sep 14 00:17:20 CEST 2004


* Tim Johnson <tim at johnsons-web.com> [040913 13:58]:
> using python 2.0+ (versions 2.0 and later)..
> 
> 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.
   
   Unix only, I guess.

  Any comments, caveats, cautions are welcome.

  Wow! Is python like a Swiss Army Knife or what?
  cheers
  tim

-- 
Tim Johnson <tim at johnsons-web.com>
      http://www.alaska-internet-solutions.com


More information about the Tutor mailing list