By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,587 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,587 IT Pros & Developers. It's quick & easy.

Set Environment for java based tools thru python script

P: n/a
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
Oct 14 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, Oct 13, 2008 at 05:07:16PM -0700, re*********@gmail.com wrote:
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)

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

Oct 14 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.