Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently using wall to show a message on a remote machine when an activity is started and finished. But this is intrusive, as it will write across an editor they might have open etc.

What I like is the "you have unread mail message" that shows up on the next line if the user presses return on the terminal.

What is this, and how can I interact with it remotely?

share|improve this question
up vote 6 down vote accepted

This line is printed by the shell. Different shells implement looking for mail in slightly different ways, but unless can count on people to configure their shells to your liking (and possibly pick a different shell), you need to send them mail.

Good shells designed for interactive use have a way to run arbitrary commands before displaying a prompt, in addition to the built-in mail notification. You can have your users cat a file there, or do something more complicated. For zsh users, put this in ~/.zshrc:

precmd () {
  if [[ /etc/sysadmin-message -nt ~/.sysadmin-message-timestamp ]]; then
    cat /etc/sysadmin-message
    touch ~/.sysadmin-message-timestamp

For bash users, put this in ~/.bashrc:

  if [[ /etc/sysadmin-message -nt ~/.sysadmin-message-timestamp ]]; then
    cat /etc/sysadmin-message
    touch ~/.sysadmin-message-timestamp
share|improve this answer
So I just write my message into /etc/sysadmin-message, or just touch it if its the same text? – IanVaughan Jul 19 '11 at 14:42
Worked a treat! From my remote machine I have ssh ${CURRENT_HOST} "echo $TEXT > /etc/sysadmin-message" in my script! – IanVaughan Jul 19 '11 at 14:46
Is /etc/sysadmin-message distro or package specific? I don't see it on my system... – Joe Internet Jul 20 '11 at 1:39
@JoeInternet It's specific to the code snippet in my post. – Gilles Jul 20 '11 at 12:56

Wall will write across open programs, but most editors have a "redraw" command of some sort to clean up anything that got written to the screen other than by the editor. The text doesn't actually break the contents of the editor.

To do what you want you will have to be creative with the precmd() function of your users shells. You will have to write up some sort of notification queue and have the users shell configuration set to check in with that queue before each command. This involves some over-head, so be careful how to write that bit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.