LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-10-2006, 09:39 AM   #1
sanjeevkchopra
LQ Newbie
 
Registered: May 2006
Posts: 14

Rep: Reputation: 0
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.
 
Old 07-10-2006, 09:55 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts & Environment Variables geeman2.0 Linux - General 12 07-05-2005 05:10 PM
Why can't my scripts set environment variables? Matthew3 Linux - Software 5 08-28-2004 05:26 PM
Need help setting right environment variables:configure scripts can't find libraries. z-vet Linux - Newbie 4 08-16-2004 05:10 PM
Environment Variables in Scripts louisb Linux - General 3 01-15-2004 04:56 PM
environment variables moeminhtun Linux - General 4 01-15-2003 09:50 AM


All times are GMT -5. The time now is 06:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration