Set Environment for java based tools thru python script

Discussion in 'Python' started by replysonika@gmail.com, Oct 14, 2008.

  1. Guest

    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, 2008
    #1
    1. Advertising

  2. Derek Martin Guest

    On Mon, Oct 13, 2008 at 05:07:16PM -0700, 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)

    iD8DBQFI9R4jdjdlQoHP510RAuYuAKCPrawhj4wM12MDJ9iLmxAGFUJGNACfTWWd
    drXo2wnIm+2W/4OYQWtSrSo=
    =XhmD
    -----END PGP SIGNATURE-----
     
    Derek Martin, Oct 14, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Turloch O'Tierney
    Replies:
    0
    Views:
    461
    Turloch O'Tierney
    Jun 16, 2004
  2. Alex Martelli
    Replies:
    0
    Views:
    414
    Alex Martelli
    Aug 18, 2003
  3. javadev_helpseeker
    Replies:
    0
    Views:
    1,335
    javadev_helpseeker
    Feb 7, 2009
  4. THTB
    Replies:
    0
    Views:
    220
  5. Max Williams
    Replies:
    3
    Views:
    193
    Robert Klemme
    Jan 6, 2009
Loading...

Share This Page