3

You know, I was just there, doing my things, when suddenly a terrible Broadcast message appeared!

fiatjaf@mises ~> sl
fiatjaf@mises ~> ls dotfiles/
urxvt
vim/
vimrc
fiatjaf@mises ~> cowsay good morning
 ______________
< good morning >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
fiatjaf@mises ~> 
fiatjaf@mises ~> 
Broadcast message from root@mises
    (/dev/pts/3) at 11:12 ...

The system is going down for maintenance NOW!

How can trigger a message like this from my own programs?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
fiatjaf
  • 158
  • 11

2 Answers2

8

man wall will give you what you need.

You execute wall with either a filename, or you pipe content to it.

For example, either,

wall file.name to broadcast the content of the file file.name or

echo "Dive\!" | wall to send the message Dive!

Update: As Stephen points out in this answer, later versions of wall can send messages by simply typing,

wall message text here

and in fact, there are additional restrictions on non-root users sending the contents of files by specifying only the file name.

EightBitTony
  • 20,963
  • 4
  • 61
  • 62
  • It works! Thank you. But why it doesn't work on `urxvt`, only on `gnome-terminal`? – fiatjaf Apr 20 '16 at 14:26
  • See http://unix.stackexchange.com/questions/150697/broadcast-messages-dont-appear-on-gnome-terminal-but-appear-on-xterm – fiatjaf Apr 20 '16 at 14:32
  • 2
    what's the output of `mesg`? "mesg n" would inhibit a `wall` (in [Linux](http://linux.die.net/man/1/wall), anyway) – Jeff Schaller Apr 20 '16 at 14:37
  • 1
    I think it's actually a known issue with `urxvt`, a quick search shows several queries asking why `wall`'s don't arrive. – EightBitTony Apr 20 '16 at 14:39
4

You simply use wall; running it as root will ensure every terminal displays the message.

wall Your attention please\!

Older versions of wall only accept a file name on their command-line, or a message piped in:

echo Your attention please\! | wall
Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164