Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'What about GUI commands?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
What about GUI commands?
Authored by: martinx on Feb 20, '03 05:13:07PM

I discovered this trick some time ago, but didn't find it useful because I
couldn't get any apps that run graphically to work.

For example, if I cd to /Applications/Calculator.app/Contents/MacOS and
run Calculator, I get:

kCGErrorIllegalArgument : initCGDisplayState: cannot map display
interlocks.
kCGErrorIllegalArgument : CGSNewConnection cannot get connection
port
INIT_Processeses(), could not establish the default connection to the
WindowServer.Abort


The same exact process works if I'm not su'ed to another user.

Am I missing something?



[ Reply to This | # ]
What about GUI commands?
Authored by: punkmanandy on Feb 20, '03 09:58:55PM

"open" will open the command on whatever users display it is executed under. if they arent logged in, they dont have a display. you can ssh in as the logged in user, and run open, and it will work.



[ Reply to This | # ]
What about GUI commands?
Authored by: schnarr on Feb 21, '03 01:51:58PM

This is similar to the way displays are handled on Xwindows with xhost set to -, only I don't think there's any way to allow all hosts to connect to OSX's display (I haven't seen one yet, at least). The purpose of xhosts on Xwindows systems is to allow other hosts to connect to and bring up windows on your display.

On an Xwindows system, typing 'xhost -' disables anyone else from sending a window to your display. If you've got X11 or XFree86 installed, try the following:
start X11
launch an xterm
xhost + (or xhost + [your machine/remote machine])
echo $DISPLAY
su - [some other user]
echo $DISPLAY
note that the display won't be set for this user, so you won't be able to launch any new Xwindows from here -
try one:
xterm
(error about Can't open display)
if using csh, tcsh, or zsh type
setenv DISPLAY [use value from DISPLAY above]
otherwise, type
export DISPLAY=[value from DISPLAY above]
xterm
the xterm is now be launched as the other user on your display.

btw, setting and leaving xhost + is a BAD IDEA, because anyone can send a window to your display, and it could look like another window you have open (tricking you into sending them information you don't want to send), or they could send you annoying pictures or ads (hey admin, Al's looking at porn again... no I'm no... - where the heck did that come from!?!).



[ Reply to This | # ]
What about GUI commands?
Authored by: discordantus on Feb 24, '03 09:40:29PM

The short answer is, no. Under Mac OS X, you can't launch an application as another user (other than root).



[ Reply to This | # ]