473,671 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$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

Sep 1 '06 #1
2 5327
On 2006-09-01, sl****@gmail.co m <sl****@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!
Sep 1 '06 #2
Grant Edwards wrote:
On 2006-09-01, sl****@gmail.co m <sl****@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

Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3820
by: Erick Bodine | last post by:
I am trying to set a new environment variable on a W2k machine with only partial success. The name("SSID") and value("ASIM") show up correctly in the registry and when I go to "System Properties"->Advanced->"Environment Variables". However, if I open a console and type 'set', "SSID" is not listed; also if I open a python shell and do os.environ the variable is not found. What am I doing wrong??? import _winreg
0
1314
by: mahongquan | last post by:
when i install moinmoin in python 2.4,windows server2000, I found it has a bug,cgiHttpServer.py set environ,but the cgi python script can not get the environ variant,such as environ,so moin donot display correct web page.
0
1346
by: jtauber | last post by:
Did something change between 2.3 and 2.4 that would affect os.environ being populated with CGI variables when using the BaseHTTPServer/CGIHTTPServer? I received a bug report from someone trying to run my wiki/blog software, Leonardo under Python 2.4 on Windows 2000. I was able to reproduce the problem under Python 2.4 on Windows XP Pro but confirmed that it worked fine under Python 2.3. Simply printing out os.environ at the point...
11
3929
by: jim.eggleston | last post by:
Windows doesn't have a HOME environment variable, but it does have HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically populate os.environ with HOME, where HOME = os.path.join(os.environ, os.environ)? If this was done, then modules such as pdb, which load resource files from HOME, would work under Windows. Alternatively, here is a patch to make pdb.py read .pdbrc under Windows.
3
7220
by: Mark Delaney | last post by:
When using the MS SQL 2005 JDBC driver, I now need to have the DNS name resolution to the client correctly set up. If not I get the following error: SQLState: 08S01 SQLError: 0 Message: hostname : hostname Where "hostname" is the client host name. It doesn't seem to matter if I
9
3739
by: boris.smirnov | last post by:
Hi there, I have a problem with setting environment variable in my script that uses qt library. For this library I have to define a path to tell the script whre to find it. I have a script called "shrink_bs_070226" that looks like this: ********************************** import sys, re, glob, shutil import os
1
7230
by: Rahul | last post by:
Hi Everyone, I once had a look at a code having the following declaration, extern ** environ or extern char ** environ... I lost the code and i'm wondering what is the exact need of this? Does anyone have any idea on this? Thanks in advance!!!
7
2412
by: Joe P. Cool | last post by:
If I call os.environ.clear in a python program child processes still see the deleted entries. But when I iterate over the keys like so names = os.environ.keys for k in names: del os.environ then the entries are also deleted for the child processes. Where is the difference? Is this a bug? (Observed in Python 2.5.2)
3
3911
by: Tim Chase | last post by:
Not sure what's going on here and hoping for some insight: tim@rubbish:~$ echo $COLUMNS 129 tim@rubbish:~$ python2.5 Python 2.5.2 (r252:60911, May 28 2008, 08:35:32) on linux2 Type "help", "copyright", "credits" or "license" for more information. False
0
8481
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.