Why I receive this error ? (setting env. variables)

Status
Not open for further replies.

eng_Semi

Full Member level 6
Joined
May 3, 2005
Messages
325
Helped
37
Reputation
74
Reaction score
6
Trophy points
1,298
Location
Egypt
Activity points
4,111
Dear ALL,

When I write this command, to set an enviromental variable:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$HCMOS9GP_DIR/UNIOPUS/uniopus_5.0.33_Lnx/tools/lib

I receive the following error:
Undefined variable LD_LIBRARY_PATH

what is the problem ?
 

I think the problem is that LD_LIBRARY_PATH is undefined.

The command you are trying evaluates the second argument and puts the result into a variable called LD_LIBRARY_PATH

If a variable called LD_LIBRARY_PATH does not exist then it will be created if the second argument is sucessfully evaluated.

The second argument you are using is ${LD_LIBRARY_PATH}:$HCMOS9GP_DIR/UNIOPUS/uniopus_5.0.33_Lnx/tools/lib

The ${LD_LIBRARY_PATH} part takes the content of an enviroment variable called LD_LIBRARY_PATH as the first part of the result. The next part of the result string is a colon. After that is the contents of the variable HCMOS9GP_DIR

The upshot of this is that the command you are trying adds an extra part on the the end of the content of an existing variable called LD_LIBRARY_PATH
The intention is to add an extra directory to a list of directorys stored in that variable.

If a varable called LD_LIBRARY_PATH dosn't exist to start with then this command fails.

You also need a variable called $HCMOS9GP_DIR to exist for this to work.

You probably want to just do
setenv LD_LIBRARY_PATH whatever_it_should_be_set_to


and for those of you trying this at home setenv is a built in command in the csh shell. It is not available in bash.

I'm not sure what the {} do offhand. They didn't make any difference on a quick test.
 

throwaway18 has explain why this problem arises. I am trying give a solution:
Code:
if (${?LD_LIBRARY_PATH}) then
    setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$HCMOS9GP_DIR/UNIOPUS/uniopus_5.0.33_Lnx/tools/lib
else
    setenv LD_LIBRARY_PATH $HCMOS9GP_DIR/UNIOPUS/uniopus_5.0.33_Lnx/tools/lib
endif
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…