Set Environment for java based tools thru python script

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

    Set Environment for java based tools thru python script

    Hello,

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


    python = subprocess.Pope n(["toolname.s h", "-args", arg1, arg2],
    stdout=subproce ss.PIPE,
    stderr=subproce ss.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 xxxxxxxxxxxxxxx xxxxxxx "$@"....

    Any Hints?

    Thanks,
    Sonika
  • Derek Martin

    #2
    Re: Set Environment for java based tools thru python script

    On Mon, Oct 13, 2008 at 05:07:16PM -0700, replysonika@gma il.com wrote:
    I run a Java app with subprocess from Python script. This python
    script is called from another Python Wrapper.
    >
    >
    python = subprocess.Pope n(["toolname.s h", "-args", arg1, arg2],
    stdout=subproce ss.PIPE,
    stderr=subproce ss.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 xxxxxxxxxxxxxxx xxxxxxx "$@"....
    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

    GPG Key ID: 0x81CFE75D


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

    iD8DBQFI9R4jdjd lQoHP510RAuYuAK CPrawhj4wM12MDJ 9iLmxAGFUJGNACf TWWd
    drXo2wnIm+2W/4OYQWtSrSo=
    =XhmD
    -----END PGP SIGNATURE-----

    Comment

    Working...