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?

fiatjaf
  • 157

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
  • 21,373
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
  • 434,908