Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-23-2005, 02:12 PM
|
#1
|
Member
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113
Rep:
|
Best way to define variables?
I need to define some variables.
I put the following at the end of /etc/profile:
export JAVA_HOME=/usr/java/jdk1.5.0_04
export ANT_HOME=/apache-ant-1.6.5
export PATH=${PATH}:${ANT_HOME}/bin
export PATH=${PATH}:${JAVA_HOME}/bin
Is there a better way to do this or is this the standard accepted way?
Thanks!
|
|
|
08-23-2005, 03:31 PM
|
#2
|
Member
Registered: Oct 2003
Posts: 568
Rep:
|
No. That works, but it will be done globally, which you may or may not want.
If you want it local only (current user) - then append it to ~/.bash_profile (if you use bash, of course.)
The correct, or accepted way to do this, is to first declare the variable, and then export it to make it available to the system.
JAVA_HOME=/usr/java/jdk1.5.0_04
ANT_HOME=/apache-ant-1.6.5
PATH=${PATH}:${ANT_HOME}/bin
PATH=${PATH}:${JAVA_HOME}/bin
export $JAVA_HOME
export $ANT_HOME
export $PATH
The way you do it works, but this is cleaner - because technically, you shouldn't declare and export all in the same go. It should be a two step process.
|
|
|
08-23-2005, 03:58 PM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
I think it depends on your distribution and other factors, such as if several people use the machine and may use a shell other then Bash or the Csh. /etc/profile is generally where the system wide login script would be located. I believe that it would run when a person logs in who uses either the bash or csh as their default login shell. I don't know about the korn shell or tsh.
Even if a particular shell doesn't use /etc/profile, I'm betting that whatever login script file it uses, will source the /etc/profile file if it exists.
One example, for SuSE, you would make the changes to /etc/profile.local and not to /etc/profile itself. Your best bet may be to to become familiar with your system and distro, and make the changes where they are expected. Things usually work out the best when you work with the system.
One alternative may be to move the settings to the linuxrc script (might be a linuxrc.local on your system). This will make the setting a part of the boot process however this may be unnecessary overkill for you particular example.
|
|
|
08-24-2005, 05:09 PM
|
#4
|
Member
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113
Original Poster
Rep:
|
I modified profile to declare and export my variables in 2 steps. Works fine.
This server will be mostly used for remote application (CVS, DB2, Tomcat, etc..) so giving those variables to everybody is ok.
|
|
|
All times are GMT -5. The time now is 06:24 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|