Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 15
Define global variable


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

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, 02:33 PM   #2
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
Add the environmental variable to your .bash_profile e.g.
export MOZILLA_FIVE_HOME=/usr/lib/mozilla
Old 03-07-2006, 03:02 AM   #3
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, 05:25 AM   #4
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:


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, 11:36 AM   #5
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

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


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 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 05:30 AM
diff between #define and const defined variable b123coder Programming 7 06-27-2005 09:02 AM
python global variable? goestin Programming 1 01-20-2005 07:52 AM
how am i define an environment variable? yenonn Slackware 2 12-19-2003 08:44 AM
how to define a global variable Anniebaby Programming 1 11-09-2003 11:43 PM

All times are GMT -5. The time now is 11:02 PM.

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