updating LD_LIBRARY_PATH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting updating LD_LIBRARY_PATH
# 1  
Old 12-22-2010
updating LD_LIBRARY_PATH

Inside my csh script, I have the following command:
Code:
source ${HOME}/.login

When I execute my csh script, why do I get the following error message:
Code:
/cygdrive/c/WINDOWS/system32/export: Permission denied

This is what I have inside my .login
Code:
#!/bin/bash
export LD_LIBRARY_PATH=/tmp:${LD_LIBRARY_PATH}


Moderator's Comments:
Mod Comment Please use code tags when posting data and code samples!

Last edited by Franklin52; 12-22-2010 at 08:43 AM..
# 2  
Old 12-22-2010
export doesn't work in csh. setenv is the builtin you need.
there is nothing to do with Shebang in this case since you are sourcing the script.

csh is trying to search for "export" ( in $PATH) and probably it has been found in the windows dir which is obviously not related to unix/cygwin.
Code:
setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH

Please have a look Csh Programming Considered Harmful
# 3  
Old 12-24-2010
Reload this Page Reply to Thread

Hi Anchal_khare,

Thanks for your suggestion.

I tried:
setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH
but after the script finished and I am back at the prompt, I checked the LD_LIBRARY_PATH and it's not updated.

echo $LD_LIBRARY_PATH

I don't see /tmp in the path.

How do I set the environment variable and have it stay in effect after the script finished?

Thanks
# 4  
Old 12-24-2010
Is there anything else you have written in your script?
the above is working for me.

Code:
$ csh
% echo $LD_LIBRARY_PATH
/opt/oracle/product/8.1.7/lib:/opt/sybase/ASE1200/OCS-12_0/lib/
% setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH
% echo $LD_LIBRARY_PATH
/tmp:/opt/oracle/product/8.1.7/lib:/opt/sybase/ASE1200/OCS-12_0/lib/
% 
% 
% echo 'setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH' > path
% cat path
setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH
% source path
% echo $LD_LIBRARY_PATH
/tmp:/tmp:/opt/oracle/product/8.1.7/lib:/opt/sybase/ASE1200/OCS-12_0/lib/
%

This User Gave Thanks to clx For This Post:
# 5  
Old 12-24-2010
I didn't source my script. Here's script of my actions

Code:
$echo $SHELL
/bin/bash
$export LD_LIBRARY_PATH=/bin
$echo $LD_LIBRARY_PATH
/bin
$echo '#!/usr/bin/csh' > test.sh
$echo 'setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH' >> test.sh
$cat test.sh
#!/usr/bin/csh
setenv LD_LIBRARY_PATH /tmp:$LD_LIBRARY_PATH
$chmod 755 test.sh
$./test.sh
$echo $LD_LIBRARY_PATH
/bin

I don't get it. The result should be /tmp:/bin

Last edited by casau; 12-24-2010 at 05:01 AM.. Reason: using [code][/code] tags
# 6  
Old 12-24-2010
If you don't source the script then the script would be executed in a different shell (sub shell) which has nothing to do with the parent shell. therefore the environment you change in the script is exists only within the script execution phase.

add this line in the script and check

Code:
echo 'echo $LD_LIBRARY_PATH' >> test.sh


I would request to explain what you are trying to do. Do you need to update the library path for some script or just want to update in your current (or may be all ) terminal?

Last edited by clx; 12-24-2010 at 05:29 AM..
# 7  
Old 12-24-2010
Hi,

My script is checking various conditions and depending on what the user wants to do, the script will setup the correct library for all terminal.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with LD_LIBRARY_PATH

I am on Solaris . I have written a script callled T_1.sh #!/bin/sh ######################################################################################################## # # Source borne shell env.This is required for crontab to work as bip.sh uses environmental variables.... (24 Replies)
Discussion started by: rafa_fed2
24 Replies

2. Shell Programming and Scripting

Ld_library_path

Hi., Currently my LD_LIBRARY_PATH setting is, LD_LIBRARY_PATH=/opt/app/product/11.2.0/client_1/lib Now, I need to append the JAVA to this setting... Can I set this way, Please suggest. ... (4 Replies)
Discussion started by: nuthakki
4 Replies

3. AIX

Set LD_LIBRARY_PATH to 1 or empty

I have a question on setting environmental variable LD_LIBRARY_PATH. The case is that, i cannot execute wget on my AIX machine. It return the following error: exec(): 0509-036 Cannot load program wget because of the following errors: 0509-022 Cannot load module... (5 Replies)
Discussion started by: cstsang
5 Replies

4. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

5. HP-UX

SHLIB_PATH or LD_LIBRARY_PATH

hi Im using HP-UX 11i,PARISC .... Where do i find SHLIB_PATH or LD_LIBRARY_PATH , i couldnt find in env, listing...... Moreover im trying to execute file its throwing me error usr/lib/dld.sl: Can't find path for shared library: libgcc_s.sl /usr/lib/dld.sl: No such file or directory... (3 Replies)
Discussion started by: vasanthan
3 Replies

6. UNIX for Advanced & Expert Users

Difference between LIB_PATH and LD_LIBRARY_PATH

I would like to know the differences between LIB_PATH and LD_LIBRARY_PATH on Linux and SunOS. I am getting an error while loading shared libraries on Linux (Omni works build environment) as shown below: 1:tradewind/dataaccess/*.pcc... (1 Reply)
Discussion started by: shafi2all
1 Replies

7. UNIX for Advanced & Expert Users

Difference between LIB_PATH and LD_LIBRARY_PATH

I would like to know the differences between LIB_PATH and LD_LIBRARY_PATH on Linux and SunOS. I am getting an error while loading shared libraries on Linux (Omni works build environment) as shown below: 1:tradewind/dataaccess/*.pcc... (0 Replies)
Discussion started by: shafi2all
0 Replies

8. UNIX for Dummies Questions & Answers

Ld_library_path

Hi, can anyone explain this terrm? should we setup it ? Thanks (1 Reply)
Discussion started by: ccp
1 Replies

9. UNIX for Dummies Questions & Answers

Bash LD_LIBRARY_PATH?

Hello I have just tried to install ns-allineone-2.31 on cygwin cygwin is using the bash shell it asks for somethings to be put into the LD_LIBRAY_PATH, here is a snippet of what it says. (1) You MUST put /home/Chris/ns-allinone-2.31/otcl-1.13, /home/Chris/ns-allinone-2.31/lib, into your... (1 Reply)
Discussion started by: bysonary
1 Replies

10. UNIX for Advanced & Expert Users

cc, setuid, and LD_LIBRARY_PATH

Hi, This question deals with Solaris 2.8 and setuid programs. From research I've done so far, setuid programs ignore LD_LIBRARY_PATH; I've proven this and am OK with it. The thing I am not certain of how the C compiler is supposed to behave when it is invoked via a setuid program. Basically,... (0 Replies)
Discussion started by: WolfBoy
0 Replies
Login or Register to Ask a Question