LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Accessing environment variables in startup scripts (http://www.linuxquestions.org/questions/linux-networking-3/accessing-environment-variables-in-startup-scripts-462624/)

sanjeevkchopra 07-10-2006 09:44 AM

Accessing environment variables in startup scripts
 
Hi All,

Can somebody tell how the value of an environment variable can made available in startup script in Linux?

I have added JAVA_HOME=/usr/java/j2sdk1.4.2_10 in /etc/profile and a shell script testEnv in /etc/init.d/.

The script testEnv looks like this:

#! /bin/sh
echo JAVA_HOME=$JAVA_HOME

When I run script with command
# /etc/init.d/testEnv
it displays the values of JAVA_HOME which was set in /etc/profile.

But when the command
# service testEnv
is run it does not display any thing.

Can somebody tell why it doesn’t displays anything OR
Where should we define JAVA_HOME so that it should be visible to startup scripts OR
How the script should be modified so that it displays the value of JAVA_HOME set in /etc/profile or somewhere, when script executed at boot level ?

Regards,
Sanjeev Kumar.

acid_kewpie 07-10-2006 09:54 AM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php


All times are GMT -5. The time now is 09:28 PM.