Results 1 to 7 of 7
Hey, I'm doing a little bit of programming with bash, and I came across a problem. I am trying to find a bash command that can send messages to the ...
- 01-25-2012 #1
Terminal to gui messages
Hey, I'm doing a little bit of programming with bash, and I came across a problem. I am trying to find a bash command that can send messages to the gui of another user, from the terminal. As to clarify, I type a command in the terminal with a message in it and it will come up on the gui of another user. It is preferable that it does not include the necessity of root access.
Thanks!!!
- 01-25-2012 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Having a prank on someone, eh?

You can use xmessage for this. It is part of the xorg-x11-apps package on my system. It does not require root, but does require connections to be allowed to the remote X Display (this can be achieved by the user running the desktop to run "xhost +"). Here's an example:
pretty simple. you need to know the ip address (if another PC) and the display number (the :1.0 part in the above case) of the display to which you want to send your message.Code:export DISPLAY=192.168.1.1:1.0 xmessage hiya
you can also use zenity (from a package of the same name), which is a GNOME-ish app that does similar things as xmessage, but much more. It You can do progress bars and file dialog boxes and such with it.
As you can see, you can define the DISPLAY as an argument to the command. This program also does not require root, but does require access (permission) to connect to the display.Code:zenity --display=localhost:12.0 --info --text "blah"
- 01-25-2012 #3
- 01-25-2012 #4might do it.Code:
who
Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.
- 01-26-2012 #5Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
You need to know two things:
1. the ip address of the X server
2. the display number of the X server
The ip address should be obvious. It could also be a hostname (and localhost ought to be valid).
The display number is not so obvious. By default, though, the initial X server running on a machine is typically :0. That is by no means a guarantee. Often, a VNC server might be running on a machine that also has X running, and so might start at 1 (and thus be :1), but again, this is by no means a hard rule.
To be sure, just run this command from with a terminal in a Desktop session that is running on the target machine to which you want the message sent (or have somebody actually using it do it):
You should get something like:Code:echo $DISPLAY
If you can remotely log into the other machine running the X server, you could look for the X server running in ps, e.g.:Code:192.168.1.1:0.0
and you might see something like:Code:ps auxww|grep X
In this case, the Xorg server is running as display 0.Code:root 1310 0.0 0.4 18748 8692 tty1 Ss+ Jan25 0:04 /usr/bin/Xorg :0 -background none -verbose -nolisten tcp vt1
- 01-29-2012 #6
I'm sorry to ask, but what if they were running mac? I just figured out and it sucks, now I have to re-write the whole script.
- 02-01-2012 #7Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
er, try a Mac forum, I guess? I don't have a Mac, so I dunno. Search for an equivalent to the DISPLAY variable for the X server in Mac (XDarwin or XQuartz or whatever).


Reply With Quote
