Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
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.
|
|
02-09-2008, 02:45 PM
|
#1
|
LQ Newbie
Registered: May 2007
Posts: 10
Rep:
|
Set/Get Linux Environment Variables
How does one view or change/set environment variables in Linux? In DOS one uses the SET command. I am using Ubuntu 6.1 Edgy Eft.
The context for my question is that for some time now I have been attempting to teach myself Xlib/Xt/Motf programming as a Linux newbie. I’m just getting into the Motif part now using Lesstif, which so far, has been compiling and working good for me at this very basic level. I finally hit chapter three of Douglas A. Young’s book “The X Window System Programming And Applications With Xt”, 1994, and I’m foundering rather badly on this chapter about resources. The first two chapters went fine, and the rest of the book looks really good, but chapter three is killing me! I’ve never run into material like this before. I’m a Windows Api programmer, and in the Windows environment these things that appear to be called ‘Resources’ in Unix/Linux are termed system settings in Windows. Application programmers usually don’t need to deal with them (at least I never have).
From my study of the aforementioned book and also Adrian Nye’s ‘Xlib Programming Manual’, I have come to understand that Xlib/Xt/Motif programs obtain Resource information from about a half dozen or more sources, and depending on rather complicated ‘precedence rules’, places this information into some sort of Resource Database ultimately located God only knows where! Intimately involved in all these machinations are a number of environment variables such as XENVIRONMENT, XFILESEARCHPATH, XUSERFILESEARCHPATH, etc. Depending on whether or not these variables are defined or not resource values can or may be read out of such files as an .Xdefaults file that itself can assume various forms and locations. This stuff is so obscure I’m wondering if I may saftly bypass it and get on to using the various widgets and their algorithims, which I find considerably more interesting and productive. But being the newbie I am I’m not sure what’s important and what isn’t.
Also, how can one determine if the root window has a RESOURCE_MANAGER property?
Thanks
Fred
|
|
|
02-09-2008, 03:26 PM
|
#2
|
Member
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585
Rep:
|
one example
# For use within a shell script. Can be lowercase. There can be no spaces
# between the env variable and the value.
MAIL_DELIVERY_COMPLETE=0
...
if [ $MAIL_DELIVERY_COMPLETE -eq 1 ]; then
...
else
...
fi
If you want this environment variable to be known outside the shell script -- the shell script runs another script that is looking for this environment variable, put an export in front of the environment variable.
export MAIL_DELIVERY_COMPLETE=0
There are some rules I've seen about upper and lower case relating to whether you are working with local or global environment variables. I have not paid much attention to these.
You should probably also read man let, because that's another way to set bash variables.
Please note export in front of a variable won't work in OSs like SCO. You'd have to MAIL_DELIVERY_COMPLETE=0; export MAIL_DELIVERY_COMPLETE.
Even if you export this variable in the shell script, it will only be available during the duration of the shell script's life. If you want the environment variable to stick around, put a "." in front of the shell script when you run it.
Last edited by cmnorton; 02-09-2008 at 03:27 PM.
Reason: shorten
|
|
|
02-10-2008, 01:02 PM
|
#4
|
LQ Newbie
Registered: May 2007
Posts: 10
Original Poster
Rep:
|
Thanks for the input cmnorton and uncle theodore. I've decided to put the whole thing aside and come back to it later if need be. It became clear to me it was a can of worms I could avoid for now. I'm making good progress in my endeavors now.
Honestly uncle theodore, it appears hard to find actual books on either XLib or Motif. I believe the two I have are about it. I saw that Jesse Liberty had a fairly new book on X programming, and the reviews of it were terrible. My XLib reference has a copywrite of 1992 on it! It still uses the old original C syntax! However, the programs work OK otherwise. I had never seen that odd syntax, but I figgured it out.
The previously mentioned Xt book is also very good, except for that strange chapter I got stuck on.
I'm assumming people use other tools nowdays to write Linux programs, and indeed, I also have a brand new and justpublished GTK+ book, but I wanted to start with the older stuff - get caught up with the history so to speak.
Fred
|
|
|
All times are GMT -5. The time now is 07:35 AM.
|
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
|
|