This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
John, To run a script from cron, you need to be able to connect to an X server, or a virtual X server (eg Xvfb). When you said you ran from a script, I assumed you were running the script at your console and not from a cron. There is no DISPLAY variable in a cron until you set one. When you log in to a consolu running X, you are running an X_init or startxwin type of script that sets up an environment for you. To use an Xvfb to generate displays, you can create a 24 bit depth server with: Xvfb :1 -screen 0 1280x1024x24 & I do that in an init.d level script at startup rather than in a user script. You can use an /etc/X1.hosts file to enable connection from a list of allowed hosts (the "1" in X1.hosts is for display :1 as invoked above). After running the Xvfb command above, you will be able to display to your `hostname`:1.0 Steve Chiswell Unidata User Support On Tue, 2004-08-03 at 15:14, unidata wrote: > Hi -- > > > Thanks for the quick response. > > > > Check to see what your DISPLAY variable is when you are running the > > > program interactively. Your default display now may not be the same > > > as what you are setting in your script. > > I had done that before -- typed env and look what display had been set at, > and set the script to that value -- with no luck. However, I also started > to do a grep search on my old emails and was surprised to see a recent > message on a similar problem ( Re: Crontab creating Gempak *.gif > images 26 July) and tried the solution. Indeed, I had no Xvfb running. > I used Mike Voss's template and got different problems. Using the script > file, gempak accepted the DISPLAY, (or perhaps choked before it got to that > part), but then gave an error on not having read/write colors (I am not sure > the exact error message, but an error type that started with N and could > have been NCLR). > > I then got your email,determined the value for DISPLAY that was the > environment for the session, set the script to that (with the Xvfb running) > and the script ran fine. I then went back and changed the script used in > the web page -- the one that alerted us to the problem -- and changed it to > that value, :0.0 , and got this response. > Xlib: connection to ":0.0" refused by server > Xlib: No protocol specified > [GEMPLT -83] NDISP - DISPLAY not set or invalid > > I then took out the setenv DISPLAY line in the web script, and added a > line that dumped the results of env to the web page, and discovered there > was no native DISPLAY value in the web's http account and got a gempak > response of > [GEMPLT -83] NDISP - DISPLAY not set or invalid Parameters requested: > > As I read it, at this stage, > 1) the web page script needs a setenv DISPLAY command line to work under > the web account. There is no global value for DISPLAY. > > 2) Xvfb needs to be running, though I am not sure the template Mike Voss > used is the right one for my system. I don't know if it needs to be > established for each account , or that it can work with one instance > running, started at boot time. > > Any ideas? > > Thanks again, > > Hobbie