 |
 |
How to send message from CLI to current user's GUI
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Location: Leesburg, Virginia
Status:
Offline
|
|
Is there a set of commands for the CLI that allows me to send a message to the current user's GUI screen?
Dominik Hoffmann
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status:
Offline
|
|
Not sure exactly what you mean, but I'd say pretty much no. I think it would be possible to write such a thing, though...
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Location: Leesburg, Virginia
Status:
Offline
|
|
Originally posted by qyn:
Not sure exactly what you mean, but I'd say pretty much no. I think it would be possible to write such a thing, though...
The situation is this:
1. I use softwareupdate from the command line to process software updates.
2. When the updates are complete I would like to send a message from the CLI of that computer to the screen, asking whoever is looking at the physical screen to reboot.
Of course I could reboot from the command line, as well. That, however, wouldn't give the logged-in users any opportunity to save their work before rebooting.
Dominik
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
Code:
sudo -u <insert target user here> osascript -e 'tell application "Finder" to display dialog "I am here"'
Depending on what you are really trying to accomplish, this might do the job. You do have to be an admin on that box, and type in your password to do so (unless you play with the suders file some).
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
There used to be a way with X11.
If someone was logged in at a workstation one could either start a 'talk' session or even open a window with a message in it. talk was the predecessor to instant messaging... been around for about 20 years. There is also the 'wall' command for broadcasting important messages to all or a list of clients. Both talk and wall are available on Mac OS X by default. See 'man talk' and 'man wall' for more details.
If the person you want to send messages to uses instant messaging (iChat, Gaim, whatever) there are commandline tools for sending IM messages. There are also perl modules for IM.
If you need this for a corporate LAN/WAN there are several IM servers available for distributing messages amongst the desktops.
See: http://freshmeat.net and http://sourceforge.net
|
|
-DU-...etc...
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Location: Leesburg, Virginia
Status:
Offline
|
|
Originally posted by larkost:
Code:
sudo -u <insert target user here> osascript -e 'tell application "Finder" to display dialog "I am here"'
Thanks! This works great.
One question, though. Why not always execute the Osax as root? That way I wouldn't have to check who is actually logged into the GUI. For me it does work without the -u option.
Dominik Hoffman
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
You have to use sudo because you have to attach to the window server that is acting on behalf of that user (you have to be able to draw on the screen). If you were doing other things you might be able to talk to the "System Events" process that runs without talking to the window server, but since you wanted to display a message...
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Location: Leesburg, Virginia
Status:
Offline
|
|
Originally posted by larkost:
You have to use sudo because you have to attach to the window server that is acting on behalf of that user (you have to be able to draw on the screen). If you were doing other things you might be able to talk to the "System Events" process that runs without talking to the window server, but since you wanted to display a message...
The point I was making was that with sudo but omitting the -u option it seems to work, too. Then I don't have to know which user is actually running the Finder. Is there any chance this would break under unforeseen circumstances?
Dominik
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|