LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2006, 01:25 PM   #1
maxmil
LQ Newbie
 
Registered: Feb 2006
Posts: 21

Rep: Reputation: 15
Define global variable


Hi,

this should be an easy one i hope.

I am running debian sarge with GNOME as my GUI.

I have an aplication that requires me to define a certain environmental variable (the application is eclipse a java IDE and the variable is MOZILLA_FIVE_HOME). If this variable is not defined in the scope of the application when it is run it causes errors.

I've discovered that executing the following two lines in a shell

$ MOZILLA_FIVE_HOME=/usr/lib/mozilla
$ export MOZILLA_FIVE_HOME

sets the enviromental variable. I can then open my application from the shell without errors.

The question is that instead of having to always do this and open my app from a shell i'd like to permanently define this enviromental variable (for all users) in a scope that will allow me to open the app from, say, a desktop icon or launch menu.

What vital piece of info am i missing, hope someone can help.
 
Old 03-06-2006, 01:33 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Add the environmental variable to your .bash_profile e.g.
Code:
export MOZILLA_FIVE_HOME=/usr/lib/mozilla
 
Old 03-07-2006, 02:02 AM   #3
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
reddazz's solution only works for your user. If you want it to work for all users, put reddazz's
command in /etc/profile instead of your .bash_profile.
 
Old 03-07-2006, 04:25 AM   #4
maxmil
LQ Newbie
 
Registered: Feb 2006
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks for both your responses but unfortunately niether of them exported the variable inside a Gnome environment.

From what i've been able to find out the problem is that when you start a new xsession no bash login is performed and hence neither /etc/profile nor .bash_profile are executed.

The solution that i have found is to create a local profile script:

/etc/X11/Xsession.d/999local-profile

with the export command in it.

This does get executed and everything works fine however i'm pretty new to linux and don't know much about the xsession startup procedure or standard conventions. I've named the script 999.... because i read somewhere that it would execute last in the startup scripts, is this correct or is there a better standard way to export variables for an xsession?
 
Old 03-07-2006, 10:36 AM   #5
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
It must be a Debian quirk because that procedure works on every other distro that I have tried.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I define a global variable? kloss Linux - General 4 02-21-2006 04:30 AM
diff between #define and const defined variable b123coder Programming 7 06-27-2005 08:02 AM
python global variable? goestin Programming 1 01-20-2005 06:52 AM
how am i define an environment variable? yenonn Slackware 2 12-19-2003 07:44 AM
how to define a global variable Anniebaby Programming 1 11-09-2003 10:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration