On 25 May, hrishy samant wrote:
> hi linux gurus
>> i wanna know where environmental variables are stored
> the file name.i am running redhat 6.2.i have installed
> xine but every time it starts it asks me to set the
> display variable.which i do by keying in
> export DISPLAY=ursula:0.0
> echo $DISPLAY
> ursula:0.0
>
Environment variables are not stored anywhere.
To get the variable set every time you log in add the export command
to your .bash_profile
general sh syntax...
DISPLAY=ursula:0.0 ; export DISPLAY
or bash specific syntax...
export DISPLAY=ursula:0.0
The export command causes a shell variable to be put in the environment
and it becomes visible to all child processes. It's passed to child processes
in an infrequently used third argument to main()
Here's a code snippet to print it out.
However don't try to modify the environment using this pointer, the whole thing is packed tight.
putenv(3), setenv(3) or equivalent must be used to modify the environment in C
#include <stdio.h>
int main (int argc, char** argv, char** envp)
{
char** ep;
if (envp != 0) {
for (ep = envp; *ep; ep++) {
printf ("%s\n", *ep);
}
}
return 0;
}
--
--Harry Moreau----------------
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!