tags:

views:

161

answers:

2

I found an odd problem when I run a simple csh script on Solaris.

#!/bin/csh
echo $LD_LIBRARY_PATH

Let's call this script test. When I run this:

shell> echo $LD_LIBRARY_PATH
shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib:/my_app/lib
shell> ./test
shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib

They print out totally different values for $LD_LIBRARY_PATH. I can't figure out why. (It's OK on my linux machine)

Thanks!

+1  A: 

Do you set $LD_LIBRARY_PATH in your $HOME/.cshrc?

You really shouldn't if you do, since it often just breaks software, but changing the first line of the script to #!/bin/csh -f will cause your script to not read .cshrc files at the start, protecting you from other users who made that mistake.

alanc
Thank you! I should think about that.
solotim
A: 

If your interactive shell is in the sh/ksh family you might have set LD_LIBRARY_PATH using "set" but not exported it. In that case it's new value will be set like a normal variable, but not exported into the environment. But it's more likely that your script is reinitializing the variable.

You can use the "env" command to dump out the exported environment from the interactive shell to check this.

Chris Quenelle
Problem solved. Thank you anyway!
solotim