os.environ is empty in JPython
james+news at daa.com.au
Fri Feb 11 09:28:28 CET 2000
In order to be secure (or something), the developers of java decided
that programmers don't really need to access environment variables.
If you want your jpython (or java) program to access the QUERY_STRING
environment variable, either write a java extension that calls getenv
for you, or wrap the program in a shell script that passes the
QUERY_STRING environment variable on the command line:
exec java program "$QUERY_STRING"
(you can probably work out what to do if you are using windows)
This second option is probably easier to do if you only need access to a
few environment variables, but if you need access to all the environment
variables, the java extension is probably the way to go.
Carsten Sessler wrote:
> in order to run some Python-Scripts as CGI I'd like to read environment
> variables. The same script running in Python delivers what I expect (the
> "QUERY_STRING") whereas in JPython the os.environ dictionary is empty. What
> can I do to get my environment or are there any other (JAVA?) methods that
> suit my needs?
> Carsten Sessler
More information about the Python-list