$HOSTNAME not in os.environ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • slinkp@gmail.com

    $HOSTNAME not in os.environ?

    Can anybody explain this one?

    pw@kermit ~ $ python
    Python 2.4.3 (#1, Jul 27 2006, 13:07:44)
    [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.
    >>import os
    >>os.environ['HOSTNAME']
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib64/python2.4/UserDict.py", line 17, in __getitem__
    def __getitem__(sel f, key): return self.data[key]
    KeyError: 'HOSTNAME'
    >>print os.getenv('HOST NAME')
    None
    >>>
    pw@kermit ~ $ echo $HOSTNAME
    kermit
    pw@kermit ~ $ uname -a
    Linux kermit 2.6.17-gentoo-r4amd64-preempt-noapic #1 PREEMPT Thu Jul 27
    12:56:53 EDT 2006 x86_64 AMD Athlon(tm) 64 Processor 3500+ GNU/Linux


    i-swear-it-used-to-be-there-ly-y'rs,

    Paul Winkler

  • Grant Edwards

    #2
    Re: $HOSTNAME not in os.environ?

    On 2006-09-01, slinkp@gmail.co m <slinkp@gmail.c omwrote:
    Can anybody explain this one?
    >>>print os.getenv('HOST NAME')
    None
    >>>>
    pw@kermit ~ $ echo $HOSTNAME
    kermit
    Perhaps the HOSTNAME variable isn't exported?


    --
    Grant Edwards grante Yow! All right, you
    at degenerates! I want this
    visi.com place evacuated in 20
    seconds!

    Comment

    • slinkp

      #3
      Re: $HOSTNAME not in os.environ?

      Grant Edwards wrote:
      On 2006-09-01, slinkp@gmail.co m <slinkp@gmail.c omwrote:
      Can anybody explain this one?
      >
      >>print os.getenv('HOST NAME')
      None
      >>>
      pw@kermit ~ $ echo $HOSTNAME
      kermit
      >
      Perhaps the HOSTNAME variable isn't exported?
      Aha. Right you are. Thanks!

      - PW

      Comment

      Working...