Saturday, October 11, 2014

linux - Set environment variables (e.g., $PATH) at beginning of script -- Not applying for all programs

I must be overlooking something, but I've tried several ways to get this to work.


I'm working on a super computer without admin rights. I need to use a specific java version for a particular program, but I don't want to make this the default java for everything.


Steps taken:
I downloaded the appropriate jre and added the following lines at the beginning of my script:


export PATH="/path/to/jre/bin/:$PATH"
export JAVA_HOME="/path/to/jre"
echo $PATH
echo ""
echo $JAVA_HOME

I get the appropriate paths when I echo during the script and, as expected, $PATH and $JAVA_HOME return to original values after the script finishes. The problem is that the programs called during the script aren't using the java I need them to (and thus fail for incorrect java version). If I run the same export commands in the shell before running the script, the programs run as expected.


I also don't have control over how java is called because I'm using a program (PBcR) that calls a series of other programs. Here's the only call in my script:


/path/to/bin/PBcR \
-length 500 \
-partitions 200 \
-l lambda \
-s pacbio.spec \
-fastq pacbio.filtered_subreads.fastq \
genomeSize=50000

Questions:



  1. Why don't all programs running during the script use the $PATH and $JAVA_HOME I export during the script?

  2. How can I get all programs called during the script to use the correct environment variables?


I've also tried putting the export commands in a separate file and calling source on that file, but that doesn't appear to change anything.


I really appreciate your help.


Running on CentOS 6.6; bash shell;

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...