15

The title sums it up. Running wall <<< "TEST" shows the message in any TTY but not in any GUI terminals ( tested with gnome-terminal and sakura ).

I have several battery and temperature monitoring scripts that rely on walling a message and after recent upgrade to 16.04 I've noticed they stopped working in GUI.

I can't determine whether this is a bug or something is preventing the messages from being displayed in GUI.

How should I proceed ?

Additional info:

Running byobu in a gui terminal does allow seeing wall messages

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 2
    Possibly related to http://askubuntu.com/questions/12654/is-there-a-way-to-have-wall-messages-show-to-desktop-users (look into xmessage, gxmessage, or notify-send) – Nick Weinberg Jun 20 '16 at 23:25
  • 6
    I've read that earlier today. Yes, somewhat related, but big objection is that 1) that question is from 10.10 , and wall has been working in 14.04 2) solutions provided there are not satisfactory for me. notify-send works for only short messages and only in GUI. wall has good convenience of using one command for all terminals, instead of writing something for tty AND for gui AND for all the other sessions that may be on other DISPLAYs , so this is not a very good alternative, at least imho – Sergiy Kolodyazhnyy Jun 20 '16 at 23:32
  • I had the same issue recently in 15.010. Im on 16.04 Ubuntu Mate, and it appears to be functional here. perhaps there is an issue in an underlying library. Maybe look at what mesg command does? does shutdown -k 5 work on all the virtual terminals? Does write function properly? I'll look at source codes if I find another machine where its not working. Im guessing its a user-space library issue. – j0h Sep 12 '16 at 15:55
  • 1
    @j0h actually, the issue is due to gnome-terminal. It used to update login records, so for example if you run who in gnome terminal before, I'd show all your open tabs but not anymore. Wall sends message only to those terminal sessions that update login records. Mate uses different terminal by default. I figured this out long ago but never actually posted an answer. Will do so at some point this week. – Sergiy Kolodyazhnyy Sep 12 '16 at 15:59
  • I have an idea how you could hack this:
    – Stancu Mihai Jan 19 '17 at 13:29

3 Answers3

7

Due to the way gnome-terminal works, wall does not register it as a terminal. A more thorough explanation can be found here. I assume that the same is true for sakura.

Based on Stancu Mihai's answer, I have created a script which mimics the way wall usually works, including the banner with user name and timestamp (use -n or --nobanner to remove the banner). The script does not currently support reading the message from a file.

You can replace the normal wall command with this one by adding an alias in ~/.bashrc:

echo 'alias wall="~/your/path/to/wall.sh"' >> ~/.bashrc

Example usage:

$ wall "some message"

Broadcast message from username@hostname (pts/19) (Wed Mar 29 11:07:35 2017):

some message

$ wall -h

Usage:
 wall [options] [message]

Write a message to all users.

Options:
 -n, --nobanner          do not print banner
 -h, --help              display this help and exit
danmou
  • 191
3

Yes it true that gnome-terminal it doesn't update login records, en because of that i try to figure out another solution:

  1. Let's find out all active pseudo terminals
ps -ef | grep " pts/" | awk '{print $6}' | sort -u | tee terminals4message.txt

This helps you to list all desktop terminal sessions.

Another way to send a message to active desktop terminal sessions

echo "$MESSAGE_to_send" | sudo tee /dev/pts/$terminal_number
  1. Don't forget about tty sesions
ps -ef | grep " tty" | awk '{print $6}' | sort -u | grep -v "pts" | tee terminals4message.txt

This helps you to list all pty sessions

  1. Sending the message to all
cat terminals4message.txt | while read TTY_TO; do echo -e "SYSTEM MESAGE: $(date) - \n MESAJ" | sudo tee /dev/$TTY_TO 1>/dev/null
  1. Now let's put it all together You can create a nice script to replace your current wall app and integrate the all above things.
    After that you can add to your ~/.bashrc alias wall="your_wall_replacement.sh" In this way you don't need to delete the current wall

Sorry if something is not right, as somebody didn't let me focus on this subject...if you guys notice something odd please leave a comment.

10x

  • 1
    Here's a one-liner for it. I replaced awk with cut so it only has one type of quote. ps -ef | grep -e " tty" -e " pts/" | tr -s " " | cut -d " " -f 6 | sort -u | while read TTY; do echo "MESSAGE" | tee /dev/$TTY 1>/dev/null; done – Chris Watts Mar 13 '19 at 16:28
1

As others suggest there are many methods, I put here a more direct (easy) method I found (adoptation of echo "$MESSAGE_to_send" | sudo tee /dev/pts/$terminal_number: discussed here.)

echo "Your message" > /dev/pts/$terminal-no

Here the terminal-no could be obtained from the other terminal through "tty" command.

tty

/dev/pts/12

damadam
  • 2,833