Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] Most reliable method to test if x server is running in a Bourne Shell script



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/08/2011 03:47 PM, Ben Eisenbraun wrote:
> On Thu, Sep 08, 2011 at 03:33:55PM -0400, Jerry Feldman wrote:
>> But, the real issue is the line: testxworking. I want a short program
>> that returns 0 if an x server is present, and non-zero if not.
>
> $ xset q > /dev/null
> $ echo $?
> 0
> $ unset DISPLAY
> $ xset q > /dev/null
> xset: unable to open display ""
> $ echo $?
> 1
>
> I would check that xset is a required part of the Xorg base installation; I
> don't know off the top of my head. If not xset, then xrdb(1) or something
> along those lines must ride along with the base installation.
>
> -ben
>
> p.s. Putty setting DISPLAY when none exists is a bug.
>
xset works fine, thanks that is all I wanted to do.
Unfortunately all the windows weenies use putty. But, people can also
set DISPLAY erroneously. I tested it from a putty session without exceed
running. (I hate exceed and rarely use it).

xset q > /dev/null 2>&1 works for me in that script.



- -- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix
PGP key id:3BC1EB90
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEVAwUBTmkgeHzqMPw7weuQAQJrLAgAlhNqDFhCV5T/2zq0WNNRE/wOS8BC1CRI
khBgKM3ClzF+2HLmyA29I3oJYC0Op/pTPL4Cqwt5WnifTizGcHFsuTYs4v4x+8g0
gerByLGBAqSbA4ZVX/9uvj+KKUY6zOe3fLBLE2Kr76WvOUvdc1/50XHZdiaRKVZC
XvR3wVQfLaoJNIFh1bAFTMsK1v0yNw3VQgsK7N+N7c3qnjD6xWYP4xAOT5gwC5s8
vP1k9yxsOgpRSTUm3Fz3+QoMjOgH8Tv/WgKP2pjCMql2PVABe0zlS8oornkY4CY5
h6IOGLIAOLFNekecSh87gHDc82YY/NG5qUA+Ta9zGZ1/vwI579TfdA==
=HyQT
-----END PGP SIGNATURE-----




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org