Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined! Vampire5's Avatar
    Join Date
    Jan 2012
    Posts
    8

    Question 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!!!

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    Quote Originally Posted by Vampire5 View Post
    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!!!
    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:
    Code:
    export DISPLAY=192.168.1.1:1.0
    xmessage hiya
    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.

    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.

    Code:
    zenity --display=localhost:12.0 --info --text "blah"
    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.

  3. #3
    Just Joined! Vampire5's Avatar
    Join Date
    Jan 2012
    Posts
    8

    Question Display

    ok, thx but how do I find the display number?

  4. #4
    Trusted Penguin jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    4,071
    Code:
    who
    might do it.
    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.

  5. #5
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    Quote Originally Posted by Vampire5 View Post
    ok, thx but how do I find the display number?
    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):

    Code:
    echo $DISPLAY
    You should get something like:

    Code:
    192.168.1.1:0.0
    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:
    ps auxww|grep X
    and you might see something like:

    Code:
    root  1310  0.0  0.4  18748  8692 tty1  Ss+  Jan25   0:04 /usr/bin/Xorg :0 -background none -verbose -nolisten tcp vt1
    In this case, the Xorg server is running as display 0.

  6. #6
    Just Joined! Vampire5's Avatar
    Join Date
    Jan 2012
    Posts
    8
    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.

  7. #7
    Linux 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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...