LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   problems with export (path) (https://www.linuxquestions.org/questions/linux-software-2/problems-with-export-path-425662/)

mac1234mac 03-17-2006 02:27 AM

problems with export (path)
 
Hello

Why this command:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/rec/parport

is working when I type it in in command line
and not when I put it in file and run it?( There are no errors
when I run the file but I know that the command is not working).

Tried to add #!/bin/bash at the beginning without success.

Cheers

timmeke 03-17-2006 02:49 AM

If there are no errors, than how can you tell that the code isn't working?
The exported $LD_LIBRARY_PATH only applies to:
-programs started after the export command (in the script that contains the export command)
-programs started from scripts that "source" (ie include) the script that contains the export command.

Running for instance:
Code:

myscript.sh:

#!/bin/bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/rec/parport

as a separate script (ie calling "myscript.sh") will execute the export command. But since there are no other programs called after the export, it will have no effect.
Once the script stops, the changed $LD_LIBRARY_PATH variable is lost as well, since it was part of the script's environment, not the environment of the shell that calls the script.

If you want to have the changed LD_LIBRARY_PATH in the parent shell, you need to "source" script.sh rather than execute it.
This is done by:
Code:

. script.sh
After that, you'll see that your $LD_LIBRARY_PATH has changed.

mac1234mac 03-17-2006 03:04 AM

How can I know?. Because I can't run program in Java. Your solution is working.
Thanks.


All times are GMT -5. The time now is 02:07 AM.