Sponsored Content
Top Forums Shell Programming and Scripting How to check if export DISPLAY is set or not? Post 302373411 by Scott on Friday 20th of November 2009 07:26:45 AM
Old 11-20-2009
Hi.

No, you can use it as-is. Place it near the top of your script.

If DISPLAY is not exported, your script won't see it and this will print a message and exit.

It's the same as
Code:

if [ -z "$DISPLAY" ]; then
  echo Display not set
  exit 1
fi

If you need to check for a specific value in DISPLAY, you can try this:

Code:
[ "$DISPLAY" != "same_host:0.0"  ] && echo Display not set && exit 1

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

export DISPLAY and XPM´s

Hi! I´ve an application that runs in a Digital Tru64, exporting display to a Linux host. That application blinks a icon (in XPM mode) when the severity mode changes. When I put a backdrop(XPM, too) in that screen, the icons blink slowly. When I remove it, they turn to blink quickly. I have... (3 Replies)
Discussion started by: selina
3 Replies

2. Shell Programming and Scripting

do a export DISPLAY

hello to begin i sorry for my english because i'am french so: someone can explain me to do a export DIPLAY with a web page (php) i have test the php function exec (myscriptshell.sh) but he can't do the export diplay. if someone have a solution . bye (1 Reply)
Discussion started by: the_nul
1 Replies

3. UNIX for Dummies Questions & Answers

difference between set and export

Hi, can anybody tell me what is the difference between set and export in unix. -Ashish (1 Reply)
Discussion started by: shriashishpatil
1 Replies

4. UNIX for Dummies Questions & Answers

How to export the Display variable

I'm trying to open an xwindow on my Sun server. What am I doing wrong? # echo $SHELL /sbin/sh # # export DISPLAY=localhost:0.0 DISPLAY=localhost:0.0: is not an identifier Thank you! (1 Reply)
Discussion started by: FredSmith
1 Replies

5. Solaris

Cant export display from aix to solaris.

Hi Frnds, i face a peculiar issue. I am managing 200 Aix workstations and 20 sun boxes. I am not anle to export the display from aix workstations to sun box, But vice versa it is working fine. But if i try to export the display to a sun box from other sun box it works perfectly. Could... (3 Replies)
Discussion started by: sriram.s
3 Replies

6. Shell Programming and Scripting

use of set, export and typeset

what is the difference in usage of set, export, typeset while declaring a value to a variable can any one help thanks (0 Replies)
Discussion started by: trichyselva
0 Replies

7. UNIX for Advanced & Expert Users

export display

hello frnds, I want to export display of othe terminal to my terminal and want to post a msg, which should visible at other terminal, I tried myself, but couldnt get it plz help me to get solution (1 Reply)
Discussion started by: sushant.pathade
1 Replies

8. Solaris

export DISPLAY

rsh to host2 from host1 and from host2 rsh into host3 Is it possible to display a GUI from host3 through host2 and onto host1? (1 Reply)
Discussion started by: eddiet
1 Replies

9. UNIX for Advanced & Expert Users

DISPLAY=local_host:0.0 ; export DISPLAY

Hi, from my Windows Workstation I can connect with PUTTY to an AIX 6.1 unix server. On AIX via PUTTY I run DBCA which has a grphical interface. Then : #DISPLAY=local_host:0.0 ; export DISPLAY $(hostname) $(whoami):/appli/oracle/product/10.2.0/db_1/bin#dbca _X11TransSocketINETConnect()... (12 Replies)
Discussion started by: big123456
12 Replies

10. Solaris

export vs env vs set commands

Hi I'm trying to understand variable scopes in solaris10. It is said that to display env variables we use 3 commands : - env - set - export What is the difference between them ? thx for help. ---------- Post updated at 11:00 AM ---------- Previous update was at 10:50 AM ---------- ... (2 Replies)
Discussion started by: presul
2 Replies
GXMESSAGE(1)															      GXMESSAGE(1)

NAME
gxmessage - a GTK-based xmessage clone SYNOPSIS
gxmessage [OPTIONS] message ... gxmessage [OPTIONS] -file FILENAME DESCRIPTION
gxmessage opens a window to display a message obtained from the command line, from a file, or from stdin. The window includes a row of but- tons, each of which causes the program to exit with a different return code. The GNU Info entry for gxmessage contains detailed information and examples. OPTIONS
gxmessage should accept any option xmessage would, although some (such as -bw and -xrm) are silently ignored. Options supported by gxmes- sage are as follows: -bg COLOR Sets the background color of the message to COLOR. Examples: red, "#c90", "#446a7e". -borderless Opens the gxmessage window without the usual window frame. This option is not compatible with xmessage. -buttons BUTTON_LIST Defines the buttons to be created. BUTTON_LIST is a comma-separated list of LABEL:VALUE pairs, one for each button. The LABEL is the text that appears on the button. The VALUE (0..255) is the code the program will exit with if that button is pressed. Commas and colons can be escaped using backslashes (). As well as ordinary text, the LABEL can specify a GTK "stock" button, like "GTK_STOCK_CANCEL", or it can include an underscore (_) to specify a keyboard accelerator. If VALUEs are omitted, they default to 101, 102, 103, etc., in order. If no -buttons option is given, BUTTON_LIST defaults to "okay:0". gxmessage -buttons "Foo:42,Bar:63" "Example" echo $? gxmessage -buttons "_Foo,_Bar" "Example" echo $? gxmessage "Example" echo $? gxmessage -buttons "GTK_STOCK_OK:0" "Example" echo $? gxmessage -buttons "Hello, world" "Example" -center Opens the gxmessage window in the middle of the screen. -default LABEL Opens the gxmessage window with input focused on the specified button. LABEL is one of the LABELs in BUTTON_LIST (see -buttons, above). -display DISPLAY Specifies the X display to use. -encoding CHARSET Specifies the encoding of the message text. By default, the message text is assumed to match the encoding of the current locale. This option is not compatible with xmessage. -entry Adds a text entry box to the gxmessage window. When the window closes, any text in the entry box will be copied to stdout. This option is not compatible with xmessage and can't be used at the same time as the -print option. -entrytext TEXT Same as -entry, but sets the default entry box contents to TEXT. This option is not compatible with xmessage. -fg COLOR Sets the message text color to COLOR. -file FILENAME Causes the named file to be used as the message source. If a dash (-) is used in place of FILENAME, the message will be read from stdin. -fn | -font FONT Specifies the message font, using GTK2's font specification system. For example, -font "serif italic 14". (GTK2's font system is not compatible with xmessage. See the Compatibility section, below, for a workaround.) -geometry GEOMETRY Sets the window's size (position is ignored by gxmessage). Example: -geometry 400x200 -help Displays basic usage information then exits. -iconic Opens the gxmessage window in its iconized (minimized) state. -name NAME Sets the gxmessage window's name to NAME. -nearmouse Opens the gxmessage window near the mouse pointer. -noescape Prevents the window closing if the ESC key is pressed. This option only works if a file named /usr/share/gxmessage/allow_noescape exists. This option is not compatible with xmessage. -nofocus Prevents the gxmessage window from receiving focus when it opens. This option is not compatible with xmessage. -ontop Attempts to keep the gxmessage window in front of other windows. This option is not compatible with xmessage. -print Writes the LABEL of the selected button to stdout. -sticky Causes the gxmessage window to appear on all workspaces. This option is not compatible with xmessage. -timeout SECONDS Automatically closes the gxmessage window with an exit code of 0 if no button is pressed within SECONDS seconds. (The -entry and -entrytext options cause -timeout to be ignored.) -title TITLE Sets the gxmessage window's title to TITLE. -version Displays the program's version number and Copyright details, then exits. This option is not compatible with xmessage. -wrap Causes lines to wrap rather than exceed the width of the window. This option is not compatible with xmessage. GTK DEFAULTS
The program's default appearance can be adjusted using GTK resource files. The main text display widget is named gxmessage-textview. The text entry widget is named gxmessage-entry. # Example: ~/.gtkrc-2.0 style "gxmsg" { text[NORMAL] = "#cc9900" base[NORMAL] = "#660000" text[SELECTED] = "#660000" base[SELECTED] = "#cc9900" font_name = "monospace" } widget "*.gxmessage-textview" style "gxmsg" widget "*.gxmessage-entry" style "gxmsg" EXIT STATUS
If a button is pressed, the program returns the value assigned to that button. The default "okay" button returns 0. If a timeout event occurs, the program returns 0. If an error occurs, or if the window is closed without a button-press or timeout event, the program exits with code 1. Pressing the ESC key also causes the program to exit with code 1. COMPATIBILITY WITH XMESSAGE
Fall back to xmessage if gxmessage isn't available: #! /bin/sh XMESSAGE=$(which gxmessage) || XMESSAGE=xmessage $XMESSAGE "hello, world" If you specify fonts, check which program you're using: font="monospace 14" [ "$XMESSAGE" = xmessage ] && font="fixed" $XMESSAGE ${font:+-fn "$font"} "hello, world" Don't use double-dashed command line options: $XMESSAGE "hello, world" -buttons good $XMESSAGE "hello, world" --buttons bad Don't use the gxmessage-specific options: -entry, -entrytext, -borderless, -wrap, -encoding, -nofocus, -noescape, -ontop, -sticky, -version, -h, -? BUGS
The position component of -geometry values is ignored by gxmessage. For some reason, opening the gxmessage window with no button set to be the default causes GTK to emit a "beep" sound. If you discover other bugs in the most recent version of gxmessage, please get in touch. SEE ALSO
xmessage(1), zenity(1), dialog(1) The GNU Info entry for gxmessage contains detailed information and examples. AUTHORS
Timothy Musson <trmusson@gmail.com> COPYRIGHT NOTICE
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Timothy Richard Musson Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are pre- served. February 25th, 2012 GXMESSAGE(1)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy