[SunHELP] $DISPLAY for root

Will Mc Donald sunhelp at sunhelp.org
Fri Aug 17 09:19:01 CDT 2001


Looks like it needs a finishing fi...

# Set the DISPLAY global environment variable.
if [ ! "$DISPLAY" ]; then
       set -A DISPLAY $(who -um)
       DISPLAY=${DISPLAY[$((${#DISPLAY[*]} - 1))]}
       DISPLAY=${DISPLAY%:0.0}:0.0
       export DISPLAY
fi

... tested with bash and ksh.

----- Original Message ----- 
From: "David Baldwin" <dbaldwin at networkinsight.com>
To: <sunhelp at sunhelp.org>
Sent: Friday, August 17, 2001 3:09 PM
Subject: RE: [SunHELP] $DISPLAY for root


> I threw that snip in my /etc/profile but when I ". /etc/profile" I get a
> syntax error.  ( is unexpected.  I checked that they all match up
> properly but I can't find where the problem is.  I am working on my
> shell scripting but I am by no means good at it.  Is there something
> else that needs to happen first?
> 
> Thanks for all the help
> Dave Baldwin
> 
> 
> 
> -----Original Message-----
> From: David Ledger [mailto:dledger at ivdcs.demon.co.uk] 
> Sent: Thursday, August 16, 2001 6:56 AM
> To: sunhelp at sunhelp.org
> Subject: RE: [SunHELP] $DISPLAY for root
> 
> >
> >  > >Hi,
> >>  >When I "su -" to any user the display is not set.
> >>  >I can't remember if this was happening always but I
> >>  started noticing it
> >>  >after installing ssh and enabling X11 forwarding.
> >>  >Note: this happens even when ssh is not in use.
> >>  >Thanks for any help or suggestions, always
> >>  appreciated.
> >>  >
> >  > >Dave Baldwin
> 
> # Set the DISPLAY global environment variable.
> if [ ! "$DISPLAY" ]; then
>        set -A DISPLAY $(who -um)
>        DISPLAY=${DISPLAY[$((${#DISPLAY[*]} - 1))]}
>        DISPLAY=${DISPLAY%:0.0}:0.0
>        export DISPLAY
> 
> should do it.  My .profile calls a script that does the above first, 
> and if that fails to give an answer it looks up the process tree to 
> find the xterm process.  My xterm starter scripts always use the 
> -display as the first parameter so it appears in a ps list for that 
> reason.
> 
> David.
> 
> -- 




More information about the SunHELP mailing list