473,836 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set Environment Variable DISPLAY

43 New Member
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 115722
prn
254 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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 Recognized Expert Specialist
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 New Member
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(versio n: 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_F ILE=/opt/intel/fc/9.1.036/licenses:/opt/intel/licenses:/home/tli/intel/licenses
TERM=xterm
SHELL=/bin/bash
HOST=donner
HISTSIZE=1000
PROFILEREAD=tru e
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=ye s
HISTFILESIZE=10 00
http_proxy=http ://192.122.223.140 :80
LIBGL_DRIVERS_P ATH=/usr/X11R6/lib/modules/dri
LS_COLORS=no=00 :fi=00:di=01;34 :ln=00;36:pi=40 ;33:so=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 :*.tbz=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=0 0;31:*.bz2=00;3 1:*.tb2=00;31:* .tz2=00;31:*.tb z2=00;31:*.avi= 01;35:*.bmp=01; 35:*.fli=01;35: *.gif=01;35:*.j pg=01;35:*.jpeg =01;35:*.mng=01 ;35:*.mov=01;35 :*.mpg=01;35:*. pcx=01;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:*.g l=01;35:*.wmv=0 1;35:*.aiff=00; 32:*.au=00;32:* .mid=00;32:*.mp 3=00;32:*.ogg=0 0;32:*.voc=00;3 2:*.wav=00;32:
XNLSPATH=/usr/X11R6/lib/X11/nls
METVIEW_DIR=/usr/local/apps/Metview
ENV=/etc/bash.bashrc
HOSTTYPE=i386
MOZ_PRINTER_NAM E=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_P REPROCESSOR=no
XCURSOR_THEME=I ndustrial
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=bi g
LOGNAME=tli
MACHTYPE=i686-suse-linux
LESS=-M -I
G_FILENAME_ENCO DING=@locale,UT F-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=lessop en.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=lessc lose.sh %s %s
G_BROKEN_FILENA MES=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_e xec($cmd);
echo "<pre>$outp ut</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 New Member
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 Recognized Expert Contributor
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
Spork Schivago
1 New Member
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
sertex78
1 New Member
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
369
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") the enivironment variable name is visible to only the sub-process created by os.system and os.popen. But as soon as the python script
28
21008
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 is: How do I export an environment variable in a .py script?
13
3028
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 *)malloc(1028); strcpy(var, "VAR="); strcat(var, argv);
1
2463
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 program's application directory, along with the DLL that contains the generic code that they both call. My question is, is there any way of modifying the environment variable permanently with the setup project, such that the user has got the...
4
39109
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 GetEnvironmentVariable("path"). However, I don't know yet how to append strings to the path variable. Any help is appreciated. Thanks a lot.
6
5339
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 = Environment.GetEnvironmentVariable("FOO");
0
1986
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 Environment Variable to the Registry and send a broadcast message to all open windows to update their environment. When I run this *.exe out of a cmd.exe, it will not update the environment of that shell. The new Environment Variable shows up
4
7574
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 variable is not in the os.environ dictionary. I know that cron runs in a subshell that does not have all of the normally set environment variables. HOSTNAME is not one of those variables, it is set even in cron's subshell. Why doesn't python get...
4
16599
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 there any way we can create user level environment variable for User2 using C# .Net 2.0. If we use Environment.SetEnvironmentVariable(envName, envValue, EnvironmentVariableTarget.User) then it will create the environment variable for the...
0
10829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10245
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7778
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5815
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4446
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.