Operating System - HP-UX
1845906 Members
5215 Online
110250 Solutions
New Discussion

Enviroment variable for 2 directories

 
Bruce Baillie
Regular Advisor

Enviroment variable for 2 directories

I have an enviroment variable that points to a vendor supplied directory. I would like to include a directory with user data. I was told I could do something like this and the 2 directories would look as one. But it doesn't work.

SYMBOL_LIB=/users/symbol_lib
SYMBOL_LIB=${SYMBOL_LIB};/vendor/symbol_lib
Why can't we all get along?
11 REPLIES 11
Robert-Jan Goossens
Honored Contributor

Re: Enviroment variable for 2 directories

Hi,

Try the same with :

SYMBOL_LIB=/users/symbol_lib
SYMBOL_LIB=${SYMBOL_LIB}:/vendor/symbol_lib

# echo $SYMBOL_LIB

regards,
Robert-Jan
David Child_1
Honored Contributor

Re: Enviroment variable for 2 directories

I don't see how the environment variable is going to make two directories look like one.

If these are libraries you want your applcation to access then as long as the application(s) in question search for libraries via the $SYMBOL_LIB variable then it should work. Basically, using the example settings you listed above, the application would first look for a library in /users/symbol_lib, then if not found it will look in /vendor/symbol_lib.

Ensure that the application will use $SYMBOL_LIB. Usually you would set $SHLIB_PATH for shared library paths so double check that.

David
Patrick Wallek
Honored Contributor

Re: Enviroment variable for 2 directories

It depends entirely on what the environment variable is being used for. If the vendors program is expecting only one item in the environment variable then anything you do is likely to break it.

If it is a search path, then you should be able to do something like:

# export SYMBOL_LIB=$SYMBOL_LIB:/vendor/symbol_lib

Note the use of the ':' (colon) character to separate the two items. In your example you have a ';' (semi-colon) which will not work.

Manish Srivastava
Trusted Contributor

Re: Enviroment variable for 2 directories

Hi,

The second definetion has a ";"
SYMBOL_LIB=${SYMBOL_LIB};/vendor/symbol_lib

replace it with ":". I think you must have got some error message too.

manish
Bruce Baillie
Regular Advisor

Re: Enviroment variable for 2 directories

I didn't realize it would be this difficult, or not possible. First off the EV is not set, it is read from a file when the application is started. I tried many different combinations, none of which worked.

SYMBOL_LIB=/vendor/symbol_lib works fine
SYMBOL_LIB=/users/symbol_lib works fine

SYMBOL_LIB=/vendor/symbol_lib:/users/symbol_lib does not work

Why can't we all get along?
Patrick Wallek
Honored Contributor

Re: Enviroment variable for 2 directories

You really need to know how the env var is being used.

If it is used in a program or script and doing something like:

${SYMBOL_LIB}/filename

then what you want to do will not work because then it would resolve to a path like:

/usrs/symbol_lib:/vendor/symbol_lib/filename

which is an invalid path.
Bruce Baillie
Regular Advisor

Re: Enviroment variable for 2 directories

Patrick, that is exactly what is happening. I guess there is no way to do it. The only reason I pursued this is, someone running the same application on a Windows machine can append the 2 directories this way.
Why can't we all get along?
Sridhar Bhaskarla
Honored Contributor

Re: Enviroment variable for 2 directories

Bruce,

Patrick had the answer. Unless this variable is used as a search path like $PATH, $SHLIB_PATH, $MANPATH etc., within your application, it is not going to work. If it is used as a search path for looking up symbols, then you will need to ask your application vendor on how they designed it to be.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Bruce Baillie
Regular Advisor

Re: Enviroment variable for 2 directories

The application is using it as a working directory with read/writes.
Why can't we all get along?
Mel Burslan
Honored Contributor

Re: Enviroment variable for 2 directories

as Patric W. indicated above, unless your application is written with this possibility in mind, i.e., this variable being used as a search path rather than a directory, it will not work. You need to talk to the developers of this application.

also, if the application is making a search in this directory to find its files, i.e., there are multiple leve directories underneath it which the application needs to access, you cann symbollicaly link your new directory under the existing one and when the search is performed, it will include this one as well.
________________________________
UNIX because I majored in cryptology...
KapilRaj
Honored Contributor

Re: Enviroment variable for 2 directories

U hv tried it all .. Why not try with a space between the directories ?

Kaps
Nothing is impossible