Set Environment for java based tools thru python script

R

replysonika

Hello,

I run a Java app with subprocess from Python script. This python
script is called from another Python Wrapper.


python = subprocess.Popen(["toolname.sh", "-args", arg1, arg2],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

I can run it manually from the command line. But fails when I execute
the wrapper Python script

How do I source the java environment from the wrapper. It fails with
the following message.

....16605 Segmentation fault $JAVA_HOME/bin/java $JAVA_OPTIONS -
classpath $CLASSPATH xxxxxxxxxxxxxxxxxxxxxx "$@"....

Any Hints?

Thanks,
Sonika
 
D

Derek Martin

I run a Java app with subprocess from Python script. This python
script is called from another Python Wrapper.


python = subprocess.Popen(["toolname.sh", "-args", arg1, arg2],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

This (toolname.sh) looks like a shell script (though technically,
there's no reason it couldn't be a python script).

Unfortunately, from what you've written here, it's neither clear what
processes start what processes, nor what the intended result is. You
have said you have 3 programs, but you've only shown the interactions
between two of them. My suggestion would be to rewrite your request,
explicitly name the processes (even if it is just with letters, A, B,
and C), and show which processes start which other processes, and
probably explain a little about what each one is supposed to do. That
said, see below.
I can run it manually from the command line. But fails when I execute
the wrapper Python script

How do I source the java environment from the wrapper. It fails with
the following message.

...16605 Segmentation fault $JAVA_HOME/bin/java $JAVA_OPTIONS -
classpath $CLASSPATH xxxxxxxxxxxxxxxxxxxxxx "$@"....

Again, it's not clear what you're trying to do, but I'm assuming you
have some script that sets environment variables, and that's what you
mean by "source the java environment..."

If so, you can't. You either need to source the environment before
running the Python program, or have the python program read a file
that contains the environment and do its own parsing, setting the
environment variables appropriately. A child process, in general, can
not insert environment variables into the environment of its parent.

If what you're trying to do isn't covered by the above, then I think
you'll need to try to explain it better.

--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFI9R4jdjdlQoHP510RAuYuAKCPrawhj4wM12MDJ9iLmxAGFUJGNACfTWWd
drXo2wnIm+2W/4OYQWtSrSo=
=XhmD
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top