• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Java Runtime class; exec method Thanks!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java Runtime class; exec method Thanks!


  • Subject: Java Runtime class; exec method Thanks!
  • From: Melissa Kimball <email@hidden>
  • Date: Wed, 11 Feb 2004 15:01:37 -0500

Thank you so much everyone for all your help!!

>>(Generally, running a simple test program is a much better idea than
>>running the final thing you really want to run: there are far fewer things
>>going on which might screw things up.)

>For example, there is a 'printenv' command which does nothing but print all
>the environment variables it has.

I did get this simple.sh shell script to work.  It would print the
environment variables to a file (WO - monitor makes it difficult to see
stdout).  It would set a new environment variable, say NEW=/some/location,
using exec(), but I couldn9t get it to append the bin9 path to the existing
path.  The reason why I chose to add an a new environment variable and
modify the PATH environment variable is because these are the required
variables needed when submitting jobs to our Sun Grid Engine.  I acquired
this information by opening a shell script that executes each time I log
into one of our Xserve nodes.

>>I can9t find any examples any where, and I9ve tried
>>different combinations to try to get it to work, and I can9t!  I9m
>>especially having a hard time with how to set the
>>PATH=$PATH:/my/new/bin?????

>The PATH variable is going to be useless.  exec() doesn't use the PATH
variable
to find executables -- you have to find them yourself.  And even if you did
exec() >a shell, it would undoubtedly instantiate it's own PATH variable,
ignoring whatever you set up.

THIS IS VERY GOOD TO KNOW!  Scrap trying to set the PATH to find SGE
executables!  Is it possible to do something like this:

    rt.exec(3/usr/local/sge/bin/darwin/qsub someScript.sh2, sge_env_var);

Of course I would put the command in a String[] to avoid the tokenizer.  I9m
thinking that there might be permission problems with trying to access
/usr/local/sge since the request is coming from the web.

>>I think you're forgetting that "$PATH" is a *shell* feature, not a Java
>>feature. You're going to have to retrieve the value of the PATH
>>environment variable as provided to your process, concatenate whatever you
>>want added, then use the result to create a "PATH=..." string to pass on
>>to the other program.

>There's no easy way to retrieve the PATH env-var.

>If such things are required, it might be simpler to use Runtime.exec() to
>execute a shell program, then feed it the command-lines you want executed.
>There are a couple ways of doing this, but the conceptually simplest is to
>pump the command-line text to the Process's output-stream.  Since the
>subprocess would be a shell, you can then use shell expressions in the
>command-list.

>I think it would make more sense to write a wrapper shell script that does
whatever setup (PATH, HOME, ...) you need and just exec() the script.  Any
variables
could be passed as parameters, which the script could either parse or pass
on to whatever tool you're trying to call.
>
>    #! /bin/bash
>
>    JAVAHOME=/Library/Java/Home
>    PATH=${PATH}:/opt/bin/mycommands
>
>    myspecialtool $1 $2 ...

I think I am going to try this approach (I9ll have so many arguments to pass
- but that is ok)!  I9ll have to put this wrapper script in a location where
it can be executed through the web by exec().

Oh - I had to subscribe to the list in order to post a question.

Thanks again!!!!
--
Melissa Kimball
UNC-Chapel Hill
Giddings Lab
919.843.3389
email@hidden
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Java Runtime class; exec method Thanks!
      • From: Jonathan Rochkind <email@hidden>
  • Prev by Date: THANKS! - Java Runtime class; exec method HELP!
  • Next by Date: Re: Licensing?
  • Previous by thread: THANKS! - Java Runtime class; exec method HELP!
  • Next by thread: Re: Java Runtime class; exec method Thanks!
  • Index(es):
    • Date
    • Thread