473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Set Environment Variable DISPLAY

43
How to set up the environment variable DISPLAY in Linux :
1- Redhat
2- SuSe

I used : export DISPLAY=donner:0.0 donner is the domain name.

it said :
you must specify the environment variable DISPLAY
e.g. setenv DISPLAY aran:0.0
or setenv DISPLAY fl1:0.0
... etc
Program terminating
DISPLAY=

Who knows, please Help !
Thank you very much.
Tanya
May 23 '07 #1
9 115515
prn
254 Expert 100+
I am going to assume you meant that donner is the hostname, not the domain name. The display must point to an individual computer, not a domain.

When you say "it said" what is "it"? The graphical program you were attempting to run? How and when did you start that program?

If you "export DISPLAY=donner:0.0" in a terminal window, the environmental variable DISPLAY is set ONLY within that specific process and others started from it. The command above exports the variable DISPLAY to itself and its "children" processes. If you set DISPLAY that way and then try to start, e.g., the GIMP from a menu or a desktop icon, then the gimp is not running within that same shell instance so it does not inherit DISPLAY from the process where you set it. Instead, you might try:
Expand|Select|Wrap|Line Numbers
  1. export DISPLAY=donner:0.0
  2. gimp &
In that case the GIMP will inherit DISPLAY from the process where you set it.

That's my best guess about what happened based on what you have said so far. If it's wrong, I won't be surprised. Come on back and tell us.

Best Regards,
Paul
May 23 '07 #2
tanyali
43
I am going to assume you meant that donner is the hostname, not the domain name. The display must point to an individual computer, not a domain.

When you say "it said" what is "it"? The graphical program you were attempting to run? How and when did you start that program?

If you "export DISPLAY=donner:0.0" in a terminal window, the environmental variable DISPLAY is set ONLY within that specific process and others started from it. The command above exports the variable DISPLAY to itself and its "children" processes. If you set DISPLAY that way and then try to start, e.g., the GIMP from a menu or a desktop icon, then the gimp is not running within that same shell instance so it does not inherit DISPLAY from the process where you set it. Instead, you might try:
Expand|Select|Wrap|Line Numbers
  1. export DISPLAY=donner:0.0
  2. gimp &
In that case the GIMP will inherit DISPLAY from the process where you set it.

That's my best guess about what happened based on what you have said so far. If it's wrong, I won't be surprised. Come on back and tell us.

Best Regards,
Paul
Yes, donner is the hostname, not domain name.
The graphical program I am attempting to run is named " xgrbplt " by using :
xgrbplt GRIB_file_name
if success, it will display a graph,
but now it returns : unable to open display "donner:0.0

another thing is after I use " export DISPLAY=donner:0.0 " and "gimp &"
then type "display" normally , a picture will display, but it returns : GIMP could not initialise the graphical user interface.
Make sure a proper setup for your display environment exists.

display: unable to open X server `donner:0.0'.
[1]+ Exit 1 gimp

what do you think of this ?
Thanks, waiting for your reply.
Tanya
May 24 '07 #3
prn
254 Expert 100+
That's odd. That's what I think.

But then X is often odd.

So let's try to go back to basics and see what we know:

1) Is donner running RedHat (version?) or is it Suse?

2) Are you logged in to a graphical interface? That is, is your terminal a window on your screen or is it the whole screen?

3) If you log out and log in fresh, what does the command "env" show? If you are using a graphical UI, then it ought to have a DISPLAY set already.

4) Are you sitting in front of donner's console or are you actually at a different computer and connected to donner by SSH or something? Or is it that you are at donner and trying to run the graphical program on some other computer but with the display set to donner?

Let us know the answers to these questions and either we can come up with something helpful or at least maybe we'll know more and better questions to ask. :)

Paul
May 24 '07 #4
Motoma
3,237 Expert 2GB
Yes, donner is the hostname, not domain name.
The graphical program I am attempting to run is named " xgrbplt " by using :
xgrbplt GRIB_file_name
if success, it will display a graph,
but now it returns : unable to open display "donner:0.0

another thing is after I use " export DISPLAY=donner:0.0 " and "gimp &"
then type "display" normally , a picture will display, but it returns : GIMP could not initialise the graphical user interface.
Make sure a proper setup for your display environment exists.

display: unable to open X server `donner:0.0'.
[1]+ Exit 1 gimp

what do you think of this ?
Thanks, waiting for your reply.
Tanya

Silly question, but have you added your machine using xhost? Does xclock work?
May 24 '07 #5
tanyali
43
That's odd. That's what I think.

But then X is often odd.

So let's try to go back to basics and see what we know:

1) Is donner running RedHat (version?) or is it Suse?

2) Are you logged in to a graphical interface? That is, is your terminal a window on your screen or is it the whole screen?

3) If you log out and log in fresh, what does the command "env" show? If you are using a graphical UI, then it ought to have a DISPLAY set already.

4) Are you sitting in front of donner's console or are you actually at a different computer and connected to donner by SSH or something? Or is it that you are at donner and trying to run the graphical program on some other computer but with the display set to donner?

Let us know the answers to these questions and either we can come up with something helpful or at least maybe we'll know more and better questions to ask. :)

Paul
1) donner is running on SuSe and the computer(version: RedHat)'s hostname is roadedit.

2) I am using roadedit logged into Suse as a root , and my terminal is a window on my screen , not the whole screen.

3)the command "env" shows :
LESSKEY=/etc/lesskey.bin
MANPATH=/opt/intel/idbe/9.1.036/man:/opt/intel/fc/9.1.036/man:/usr/local/man:/usr/share/man:/usr/X11R6/man:/opt/gnome/share/man
INFODIR=/usr/local/info:/usr/share/info:/usr/info
NNTPSERVER=news
HOSTNAME=donner
XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
GNOME2_PATH=/usr/local:/opt/gnome:/usr
INTEL_LICENSE_FILE=/opt/intel/fc/9.1.036/licenses:/opt/intel/licenses:/home/tli/intel/licenses
TERM=xterm
SHELL=/bin/bash
HOST=donner
HISTSIZE=1000
PROFILEREAD=true
EMOSLIBOLD=-L/usr/local/lib_intel -lemosold
BUFR_TABLES=/usr/local/bufr_intel
MORE=-sl
QTDIR=/usr/lib/qt3
USER=tli
JRE_HOME=/usr/lib/jvm/jre
GROFF_NO_SGR=yes
HISTFILESIZE=1000
http_proxy=http://192.122.223.140:80
LIBGL_DRIVERS_PATH=/usr/X11R6/lib/modules/dri
LS_COLORS=no=00:fi=00:di=01;34:ln=00;36:pi=40;33:s o=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33; 01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*. bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tb z=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj= 00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.zoo=00 ;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.t b2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bm p=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg =01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=0 1;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01; 35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35 :*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*. au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc =00;32:*.wav=00;32:
XNLSPATH=/usr/X11R6/lib/X11/nls
METVIEW_DIR=/usr/local/apps/Metview
ENV=/etc/bash.bashrc
HOSTTYPE=i386
MOZ_PRINTER_NAME=pcol1
FROM_HEADER=
PAGER=less
CSHEDIT=emacs
XDG_CONFIG_DIRS=/usr/local/etc/xdg/:/etc/xdg/:/etc/opt/gnome/xdg/
MINICOM=-c on
PATH=/opt/intel/idbe/9.1.036/bin:/opt/intel/fc/9.1.036/bin:/home/tli/bin:/usr/local/bin:/usr/bin:/sbin:/usr/X11R6/bin:/usr/sbin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin
MAIL=/var/mail/tli
CPU=i686
JAVA_BINDIR=/usr/lib/jvm/jre/bin
BUFRTAB_DIR=/usr/local/bufr_intel
PWD=/home/tli
INPUTRC=/home/tli/.inputrc
JAVA_HOME=/usr/lib/jvm/jre
MAGLIB=-L/usr/local/lib/magics/lib -lmagics -lMvDevices -L/usr/local/lib/magics/lib -lmagics -L/usr/lib -lGLw -lGLU -lGL -L/usr/lib -L/usr/X11R6/lib -lgd -lpng
-lz -ljpeg -lfreetype -L/usr/X11R6/lib -L/usr/lib -lXm -lXt -lXmu -lXi -lXext -lX11 -lXp -lm -L/usr/lib -lstdc++ -lm
EDITOR=/bin/vi
LANG=en_GB.UTF-8
PYTHONSTARTUP=/etc/pythonstart
TEXINPUTS=:/home/tli/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX
HOME=/root
SHLVL=2
EMOSLIB=-L/usr/local/lib_intel -lemos
MAG_HOME=/usr/local/lib/magics
OSTYPE=linux
LESS_ADVANCED_PREPROCESSOR=no
XCURSOR_THEME=Industrial
LS_OPTIONS=-A -N --color=tty -T 0
WINDOWMANAGER=/usr/X11R6/bin/gnome
GTK_PATH=/usr/local/lib/gtk-2.0:/opt/gnome/lib/gtk-2.0:/usr/lib/gtk-2.0
F_UFMTENDIAN=big
LOGNAME=tli
MACHTYPE=i686-suse-linux
LESS=-M -I
G_FILENAME_ENCODING=@locale,UTF-8,ISO-8859-15,CP1252
CVS_RSH=ssh
ACLOCAL_FLAGS=-I /opt/gnome/share/aclocal
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/etc/opt/kde3/share/:/opt/kde3/share/:/opt/gnome/share/
LESSOPEN=lessopen.sh %s
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/kde3/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/share/pkgconfig
ARCH=LINUX
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:/opt/gnome/share/info
LESSCLOSE=lessclose.sh %s %s
G_BROKEN_FILENAMES=1
COLORTERM=1
JAVA_ROOT=/usr/lib/jvm/jre
mc=() { . /usr/share/mc/bin/mc-wrapper.sh
}
_=/usr/bin/env

4) I am using my computer named roadedit(Redhat) logged into donner(Suse) as a root to use this command "xgrbplt" which returns a graph in a window on my screen.

and the question is ( this is actually what I want to do ! ) :
donner is the server, I want to use this page( using Firefox ) either on my computer or donner itself .
http://donner.aaa..../~lmcelwain/xgrbplt.php in this page
I embedded shell command in php :
the code is :
/*
<?php
$name = $_POST['gname'] ;
chdir("/home/lmcelwain......");
echo $name ;
$cmd="xgrbplt $name";
$output=shell_exec($cmd);
echo "<pre>$output</pre>";
?>
*/

I have used this way with other shell command , and it worked.
but here, result is :
-----------
SCRATCH=/18475
Running xgrbplt.x
You must specify the environment variable DISPLAY
e.g. setenv DISPLAY aran:0.0
or setenv DISPLAY fl1:0.0
... etc
Program terminating
DISPLAY=
------------
I got the same result from that page( http://donner......) either on donner or my computer.

result expected from this page should be a graph displayed in a window in a terminal or a web page, I am not sure, bcs I never get it work.

Paul, Thanks for you attention !
Tanya
May 25 '07 #6
tanyali
43
Silly question, but have you added your machine using xhost? Does xclock work?
xclock works on my computer , hostnam: roadedit, RedHat
xclock does work on donner.
xhost works on neither.
May 25 '07 #7
prn
254 Expert 100+
Hi Tanya,

I think I'm starting to get a little better picture of what you're doing, but to the extent that I understand that, I think I see a number of problems.

First, stop running as root. Overall, that's a really bad idea. The root account needs to be used for various admin tasks, but you should have a "normal" user account (on both machines) for user-level tasks. For what you are doing here, you really don't want to be root. For web surfing, or generating graphics of whatever sort, log in as a normal user. One of the big problems with most MS windows systems has always been that users have needed admin privs for trivial tasks that should not have admin privs. A result of that has been that there are too many ways to seriously mess up the whole system. With Vista, MS has moved toward requiring a better separation of privs and that is all to the good. Unix/Linux have always had a pretty good separation of privs (some OSs are even better about that, but that's a whole nother discussion). Learn to run as a user and you will definitely save yourself problems in the future.

Second, it looks like your connection from roadedit to donner is probably by telnet or rsh. Switch to using SSH. You won't regret that either. It's much more secure.

Third, since you are using roadedit as your screen, that's where you want the results of the graphing displayed. If DISPLAY is on donner:0.0 (i.e., the console), you will never see the results, since you are not looking at donner's console. Before you do anything more run the command:
echo $DISPLAY
on roadedit. You will probably see something like:
:0.0
This indicates that your DISPLAY envirionmental variable is properly set on roadedit, where you actually are. You could set DISPLAY on donner to point to roadedit:0.0 too, but there is a better way.

If you take recommendation #2 above and use SSH to connect from roadedit to donner, then you can set it to handle DISPLAY automatically:
Edit /etc/ssh/sshd_config on donner. You should find the line containing "X11Forwarding". It may say:
#X11Forwarding no
It needs to say:
X11Forwarding yes

On RedHat systems, if you changed /etc/ssh/sshd_config you will need to use the command:
/etc/init.d/sshd restart
I suspect SUSE will be similar, but I'm not positive about how the init scripts are set up on SUSE. They may be in a slightly different location.

Once sshd is correct on donner, you should now connect from roadedit to donner using a command like:
ssh -Y tanya@donner
(Note that the Y is capitalized.) Now, on donner when you say:
echo $DISPLAY
you should see somthing like:
localhost:10.0

If you try
xclock &
on donner, your xclock should appear on roadedit's screen because your display is now "tunneled" through your ssh connection back to roadedit.

If that all worked, you should now be able to run xgrbplt on donner directly from the command line and the result will show up on roadedit's screen.

I'm less confident that you can run xgrbplt by means of a script in a web page and have the result show up in your browser window on roadedit. The script you have strikes me as pretty unlikely to work regardless of your environment variables. That sort of script works great for text, but I don't think you can do that for arbitrary graphics. If xgrbplt can output graphics in a file format that browsers understand, e.g., png or jpeg, then the script might be adapted, but it certainly won't work for just any graphics that your X11 display knows how to render. Googling for "xgrbplt" produced no hits, so I don't have any clue at all about its capabilities.

So if you just want the graphs for yourself, then you can see them using ssh, but if you are trying to make them available to a larger audience using a web browser, then you are going to need to make xgrbplt (or some other program) produce suitable intermediate files that you can put into a web page. I don't think setting DISPLAY is going to help you there. (And I don't know if xgrbplt is capable of producing png, jpeg or similar files anyway.) For this to work, you would need to have a way to turn off xgrbplt's requirement for DISPLAY and make its output go to a suitable file in a location where you can put an IMG tag in your generated HTML.

HTH,
Paul
May 25 '07 #8
I'm sorry to dig up an old thread here but I came here looking for answers. I had the same problem, I couldn't start any GUIs from a terminal. I'm running OpenSuSE. I did manage to find the problem though.

If I start a regular terminal window and run su to switch to root, I can simply run:
Expand|Select|Wrap|Line Numbers
  1. export DISPLAY=:1
  2.  
Where :1 is my X-Windows display.

However, if I start the terminal window with something like this:
Expand|Select|Wrap|Line Numbers
  1. /usr/bin/gnome-terminal -e pkexec
  2.  
So it starts a root terminal instead of a normal user terminal window, setting the DISPLAY variable is not enough.

On my system, I had to run these two commands to properly be able to start a GUI program, as root, from a terminal window.
Expand|Select|Wrap|Line Numbers
  1. export DISPLAY=:1
  2. export XAUTHORITY=/run/user/1000/gdm/Xauthority
  3.  
If the .xauth* file exists under the /root directory, then just set XAUTHORITY to that.

For example:
Expand|Select|Wrap|Line Numbers
  1. eugene:/home/spork # ls /root/.xauthMPjGOB
  2. /root/.xauthMPjGOB
  3.  
  4. eugene:/home/spork # export DISPLAY=:1
  5. eugene:/home/spork # export XAUTHORITY=/root/.xauthMPjGOB
  6.  
Depending on your distro, the .xauth* file might be in a different directory. For example, on Arch, I believe it's:
Expand|Select|Wrap|Line Numbers
  1. /home/non-root-usersname/.Xauthority
  2.  
Just figure out where the .Xauthority file is for the user that's running X-Windows and set the environmental variable to that for root to run graphical programs from the terminal.

I hope this helps other people who come here looking for answers as well.

Thanks!
Dec 2 '16 #9
I fixed by making sure X11 was been forward in ssh_confg file

cat /etc/ssh/ssh_confg see if under Host *
# ForwardX11 is the to no if it is then sudo vi/etc/ssh/ssh_confg
and delete the comment # and set it to yes then shift ZZ and try again.
Jan 19 '17 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: tuxlover | last post by:
Is it possible to set an environment variable from inside the python script which will be retained after the script exits. If I use the following code: import os os.putvar("name", "tuxlover")...
28
by: Christian | last post by:
Another question from a not even newbie: In Unix you can set an environment variable with the command export PYTHONPATH but I would like to set the variable from at .py script. So my question...
13
by: Jimmy Cracker | last post by:
Is it completely impossible in UNIX to push an environment variable to the parent shell? I would like to do something like this: main(int argc, char *argv) { char *var; var = (char...
1
by: Bonj | last post by:
Hi My application installs a front-end GUI, which runs code when buttons are clicked. It also installs a command-line utility, that is a console application. They are both installed to the...
4
by: | last post by:
Hi all, I am trying to append a certain string to the PATH environment variable programmatically. I am able to read what is in the variable using the System.Environment method...
6
by: yaron | last post by:
Hi, my application use environment variable, let call it FOO. how can i add the FOO environment variable to my project or my solution, so the line string foo =...
0
by: Joe HM | last post by:
Hello - I am putting together a little ConsoleApplication that is supposed to check for an Environment Variable and create it if it does not exist. I found some code that will add a new...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
4
by: vkbishnoi | last post by:
I need to create an environment variable for another local user in windows. For example, say suppose there are 2 users in the system (User1 and User2). Currently User1 is logged in the system. Now Is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.