• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting environment variables - Linux  RSS feed

 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question regarding Environment variables in Linux. I am not well-versed in the Linux environment so I am not sure if I will be able to explain my requirement using the correct technical jargon. Anyway, here goes.

I need to have an environment variable DISPLAY set to some value, so that when a particular user opens a terminal window that variable is available (similar to MyComputer -> Advanced -> Environment Variables). Even if it is available to all users it is fine, but preferably only a particular user.

Currently I use "export DISPLAY=:1" in one terminal window. But obviously if I open another terminal window this value is not set. But this is exactly what I want.

How would I achive this:
a) during bootup of the pc
b) when the pc is already running and does not have the required environment variable set.

Any information or links to sources of information would be of great help. Thanks a lot.
Sheldon Fernandes
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
during bootup, you could set:

/etc/profile
:


I don't use DISPLAY here, because I cannot recommend it.

I'm not an X11-expert, but obviously, DISPLAY is set during start of X11 dynamically.
It's set for the desktop, and not for a user, especially not for all users.

And on the localhost, it's not a particular user, opening a terminal window, but it's allways the same user - the one who started X11, for whom a new terminal is opened.

Under X11, openening a xterm I get

The same user on the CLI

(de rien)
a different user nothing too.
If I use /bin/su in the xterm, and get root, and echo $DISPLAY, then I get :0.0 too.

If a remote user logs in via ssh or telnet, he has to tell whether he wants to use X11 or not.

then he has to specify his display, to see the output:


I guess you will break all these things, but if your environment isn't working correctly, things might be already broken somehow.

Breaking or not, DISPLAY or FOOBAR, I don't know a command to set a variable for all users - logged in or not - from a central place to a specific value.
 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for taking the time to reply.

The reason I posted this question was as an alternate solution to my problem which you might have already seen in the BEA Weblogic Forum.

I will try the bootup option you suggested.

Not knowing much about Linux (and X servers) has been a real hindrance to me in getting the issue resolved.
Thanks again.

Sheldon Fernandes
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although adding the DISPLAY set command in /etc/profile will cause that veriable to be set in all circumstances where /etc/profile gets run (see your favorite shell's docs for details), there's usually some sort of setting done when you bring up X and that might even override your /etc/profile, depending on what got executed when.

X is a client-server windowing system. Normally these days the client and server are on the same machine, so the default is to set DISPLAY to the user's primary local video display, and nothing more need be done.

You're asking about this in regards to WebLogic, so I have to ask:

Are you trying to provide access to JDK graphics functions in webapps? If so, the magic word is "headless". Playing games with the X system is not the way you'd want to go. JDK1.4 has a specific addition for that mode.
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I read your post over on WebLogic more closely. You are trying to run headless, and yes, xvfb would support you unless your chart package has some insane idea of talking real-time interactive to an X terminal (which won't work over the Internet). Normal on-the-page graphics are such as rendered by awt and the java 2d classes are not a problem.

However, like I said, JDK 1.4 has an alternative mode that bypasses the X client (X is backwards on who is client and who is server). Using the Java headless option causes the Java graphics routines to bypass the X process and invoke the X libs directly.

The reason Java doesn't do low-level graphics itself is A) it's already bloated enough and B) most modern-day systems have graphics acceleration hardware on their video cards and the X libraries (or for Windows Java, the GDI.DLL) will ask the video hardware for assistance. Fun fact: did you know Windows printer drivers often use the video card for graphics assistance too?

Which means that graphically-inclined servers benefit by having fancier video cards even though you may never physically plug a display unit into them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!