Overriding PATH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Overriding PATH
# 1  
Old 02-06-2008
Overriding PATH

Hello,

I'm using Sun solaris .

I'm trying to override the environmental variable in my script, however when I execute the script, the PATH whatever being set in .profile is taking precedence.

I have done the sanity checks like order of my entry in path, permissions for the user etc.,

To be precise, I have two versions of Java in my server , my .profile refers to java1.4, however for a specific application which is trigerred from bash shell script,I want to use Java1.6.

Code:
#!/bin/bash
JAVA_HOME=/export/home/def/java/jre
export JAVA_HOME

PATH=$JAVA_HOME/bin/sparcv9:$PATH
export PATH

LD_LIBRARY_PATH=$JAVA_HOME/lib/sparcv9:$JAVA_HOME/lib/sparcv9/server:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

CASSPATH=/export/home/def/Scripts/XL/:/export/home/def/Scripts/XL/jar/bin/xalan.jar:/export/home/def/Scripts/XL/jar/bin/xercesl.jar;
export CLASSPATH


echo "java home is ----> $JAVA_HOME"
echo "\n"
echo "java path is ----> $PATH"
echo "\n"
echo "java LD_LIB is  ----> $LD_LIBRARY_PATH"
echo "\n"
echo "java classpath  is  ----> $CLASSPATH"

echo "\n"
echo "java instance ----->"`which java`
echo "\n"
echo "java version ----->"`java -version`

java app1 start


I'm epecting this script to calll the java instance set in JAVA_HOME, however it still calls the /usr/bin/java (being set in .profile).
However if I change the values of environmental variables provided above in .profile, then I'm able to call the appropriate java version.
I don't wanna apply this change for the entire user but for just the session.
Can I not override environmental variables for a session alone ?

Thanks
# 2  
Old 02-06-2008
You must have an alias set for java which points to /usr/bin/java or whatever: to check try:
Code:
alias | grep java

This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. Shell Programming and Scripting

[Solved] Help with Overriding a Prompt in UNIX/Java

I am executing a shell script which contains a jar call to an external java package for which I don’t have a read access to. The external package was written in such a way that whenever we make a java –jar call to the package, it shows a prompt on the console asking if we want to continue or no... (1 Reply)
Discussion started by: Harry1302
1 Replies

3. UNIX for Advanced & Expert Users

Overriding Mailx Command

Hello All, I am working on a project where the requirement is override mailx command in such way that, instead of sending mailing to email addresses coded in codes, it should send mails to one common email address at run time. We do not intend to change the email addresses in codes. This... (1 Reply)
Discussion started by: shubh05
1 Replies

4. Shell Programming and Scripting

Overriding XML File

Hi All, I have an XML file (normally >3mb). I need to loop through this and override with some new (correct) values. Here is a row of data:- <row> <field name="ID">1</field> <field name="Type">a</field> <field name="value1">xxx</field> <field name="value2">xxxx</field> ....... (3 Replies)
Discussion started by: robfwauk
3 Replies

5. UNIX for Dummies Questions & Answers

ftp - check if file on remote exists (skip overriding)

Hello, I have a script that uploads a file from local to remote place using ftp. The problem is that, if on remote host there is a file called the same as the one I want to upload, the ftp program overrides that file. But I don't want to override nothing (even if the remote file is older,... (3 Replies)
Discussion started by: spiriad
3 Replies

6. Programming

C++ overriding Vs hiding

class B { public: void fns(void){//base def;} }; class D:public B { public: void fns(void) {//new def;} }; I was thinking the above is overriding but somewhere else i found the above is just hiding.Only virtual functions can be considered as overriding? This is the exact statement ... (1 Reply)
Discussion started by: johnbach
1 Replies

7. UNIX for Dummies Questions & Answers

overriding the mask in setfacl

hello everbody: Im trying to give the user "ydarwish" a full access over some directory on my sol9 machine. however the setfacl is recalculating the mask parameter keeping me from keeping him effective write and read access: root@Obi-Wan> setfacl -m u:ydarwish:rwx /IN_ARCHIVE6 root@Obi-Wan>... (4 Replies)
Discussion started by: aladdin
4 Replies

8. Programming

overriding the dynamic library

Hi, I wonder how can we override the dynamic library loaded by ld on start up.(dynamic linked application). so that linker uses the new library to find symbols. Is it possible to do. Cheers. (4 Replies)
Discussion started by: Raom
4 Replies

9. IP Networking

overriding /etc/resolv.conf with .nslookuprc file

Hi, I have come across a fact that /etc/resolv.conf can be overrided by using ~/.nslookuprc. Is this completely true...i.e can I completely override /etc/resolv.conf. If so, can I have a list of my own domainnames & Nameservers in ~/.nslookuprc that can override those in resolv.conf. ... (3 Replies)
Discussion started by: smanu
3 Replies

10. AIX

overriding function calls without recompiling

i want to replace the *alloc and free function calls in an existing project with my own functions, to be able to log the adresses etc in a text file. (memoryleak debugging) I think LD_PRELOAD is what i am looking for. That way i could create a Library with my own malloc functions and link them... (1 Reply)
Discussion started by: Lazzar
1 Replies
Login or Register to Ask a Question