We have relaunched: What's new at ZDNet Asia?

Send messages and alerts from the command line

Summary

Here's a look at two command-line programs, wall and mail, that allow you to send simple alerts and e-mail messages to users.

Events

Microsoft MSDN/Developer Event
25 Mar 2010

One Marina Boulevard, Microsoft Singapore

IT Architect Regional Conference Singapore 2010
20 - 21 Apr 2010

Singapore Management University, Singapore

The Internet Show 2010
21-22 Apr 2010

Suntec Singapore

The command line is a great environment for doing many things. It can be used to schedule commands, navigate directories, chain simple commands together to create complex commands, automate system monitoring, and more.

The flexibility that the command line offers makes it worth investing the time into learning more about it, as its power far exceeds that of GUI operating environments.

CLI environments, especially with multi-user systems such as servers, provide a great way to communicate between users as well. Two tools in particular are of great value: wall, which will communicate messages on all active consoles, and mail, which will send e-mail via the command-line.

Wall is an interconsole "instant messenger" and is available on all Linux and UNIX systems. With it, you can broadcast alert messages, such as an impending system reboot or other maintenance process.

Using wall is simple:

$ wall "just fooling around"

Broadcast message from vdanen (pts/16) (Mon Aug  4 20:47:03 2008):

just fooling around

Any user logged into the system will see the identical notice. The only exception is when a user has set their "message" flag off. For instance, to disable seeing these wall notices, use:

$ mesg n
$ mesg
is n

The mesg command takes exactly one of two arguments: y and n; if no argument is supplied, it shows the current message value.

Another useful tool is the mail command, which will send e-mail messages on the CLI. This can be used in conjunction with a command such as at to send reminder e-mail messages, or it can be used to send an alert when a task or command is complete.

There are a few different providers of the mail command; some distributions use the mailx package, others use nail, others the original Berkely mail package. If mail doesn't work as expected, read the mail(1) manpage. Most mail commands use the same syntax for the basics, however.

To send an e-mail to an SMS relay to alert you of an upcoming meeting, use:

$ echo "20 minutes to meet with Sally." | /bin/mail -s "Meeting"
sms@myhost.com

This will send an e-mail with the subject "Meeting" to sms@myhost.com; the body of the message will contain, "20 minutes to meet with Sally". As has been illustrated, this can be used as a quick means of sending reminders, or it can be used to send the output of jobs when completed. The mail command takes standard input as the body of the message; other options can be used to specify CC and BCC recipients as well.

E-mail messages sent via mail are sent from the calling user on the system's hostname; for instance, if the user account joe were sending this on the system foo.bar.org, then the e-mail would be seen to come from joe@foo.bar.org. Because of this, you may want to ensure proper message rules are in place that permit the relaying or reception of these addresses, or adjust the hostname of the computer accordingly.

Talkback

Email from Ubuntu

Thanks for your nice article.
Question: How can I send an alert message via mail to one of my clients in same network?

I need to send a message via mail or alert to only one of the clients!

Thanks alot

vakili February 7th, 2009 Reply
Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment
Transform your business interactions with real-time voice, video and telepresence solutions.
Tech Vendor: Cisco

ZDNet Asia Live

RT @mistertechblog: I wrote about Nexus One and Touchdown, desktop dock, Bluetooth/USB tethering, ebooks here: http://bit.ly/bRdzx0

6 hours 21634 seconds ago by yklee13 on topsy

Read my blog post on getting the most from your Nexus One: http://www.zdnetasia.com/blogs/m...

Data Centre Operator (Fresh Graduates Welcome to Apply) in ... http://bit.ly/bagYuu

6 hours 30 minutes ago by intmasterfeed on topsy

#Cisco #Cloud Cloud on ZDNet Asia: Aussie university joins Cisco cloud ยท Early-adopter criminals embrace cloud... http://bit.ly/d93C8S #TCN

7 hours 33 minutes ago by thetechgang on topsy

www.3w.com.au has seen it's outsourced IT Contracting Business in Manila grow at 4 times the rate of its traditional Australian Based...

14 hours 11 minutes ago by brucemills on Companies' outsourcing spend to increase

RT @3wconsulting: Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oY9f

Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oYbA

Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oYbz

Zdnetasia.com Estimated Worth $178,365 USD. Daily Ad Revenue:$244 USD, Daily Views:81,445 Pages... - http://www.haplog.com/www.zdneta...

recently estimated website net worth of zdnetasia.com - http://www.haplog.com/www.zdneta...

1 day 4 minutes ago by haplog on topsy

When I create an event, I click on an approximate time during the day when I want the event to occur, then I click "edit event detail...

1 day 40 minutes ago by bessellbrowne on Google Calendar gets 'smart' rescheduling

ipads break alott i had one it broke three times in the month i had it so i got rid of the damn thing id just go for the laptop Top Grade...

1 day 42 minutes ago by bessellbrowne on Report: 'Hundreds of thousands' of iPad preorders

There are a number of websites that still require Internet Explorer to view and IE for Mac Stinks (it is really ies4osx which is the Wind...

1 day 43 minutes ago by bessellbrowne on Microsoft: Only minor tweaks in Windows 7 SP1

The receivers don't transmit back to the satellite. Unless there is a phone line attached to the receiver, they don't have any wa...

1 day 46 minutes ago by bessellbrowne on Apple to join the geolocation craze?

"Lead Cognos BI Developer Insurance - Jobs - ZDNet Asia" http://bit.ly/bRcxOG

1 day 41 minutes ago by rhrcognos on topsy

whatever little understanding I have we 'll only progress toward end of the world if we use HPCs to lenthen life of human being. Huma...

2 days 53 minutes ago by abhi32002@gmail.com on High computing promises elixir of life

Thanks for the knowledgeable article on SDDs. Allas...when all this reasearch will happen in Indian Universities. Hope the new bill on Fo...

2 days 6 minutes ago by abhi32002@gmail.com on APAC HPC users eye solid-state drives

It was a good article. This brings a good opportunity for Indian IT firms to come up with new solutions in this field. HPC can become a b...

2 days 24 minutes ago by abhi32002@gmail.com on High computing most-wanted job in Asia

COL KR DHARMADHIKARY(RETD) its very late to reply the link, but if it is still alive and looking for opportunity, i would like to know th...

2 days 22 minutes ago by deb021280 on Education takes off in rural India, helped by PCs

It was just a matter of time until google was marginalised anyway. I'm afraid this will be forgotten in China very quickly. Still, it...

2 days 26 minutes ago by robinsmith on Report: Google to leave China on April 10

High performance computing (HPC) most-wanted job in Asia http://bit.ly/9vFC3i (via @zdnetasia) #singapore

He doesn't care if her shoes are of glass, All he wants to see is a huge rack and nice a*s. Sleeping beauty's not awoken by true ...

2 days 55 minutes ago by warlowdavies on One pair of 3D glasses to rule them all

RT @zdnetasia: EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. (cont) http://tl.gd/i5jjd

EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. http://bit.ly/9etOZW

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08 via @zdnetasia

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08

[TECH] URL Shorteners slow Web redirection. - http://bit.ly/bySnWK @zdnetasia

URL shorteners are great but they can slow web redirection & you pray it would never go down http://bit.ly/bySnWK via @zdnetasia

URL shorteners slow Web redirection. http://bit.ly/bySnWK

Chinese agencies cry foul over Google. http://bit.ly/by6rwV

all of sg's isps have been practising compulsory invisible proxy for all home subscribers at their backend since many years back alre...

3 days 5 minutes ago by melvinchia on Web filters mean bad news for business

it is not to good for china.
Proactol

3 days 50 minutes ago by nathonastle on Chinese ad partners beg Google for information

Very good explanation of JMX

4 days 55 minutes ago by Babith B on Managing applications with JMX

The reaction to a report issued Tuesday by Flurry Analytics managed to completely overlook some interesting news--the Android-based Motorola Droid outsold the original iPhone over the same period of time following their respective launches--to focus instead on the sales numbers for the Nexus One.

4 days 59 minutes ago by lonemavericks on diggs

Another ZTE story....

4 days 1 minute ago by Moderate Your Greed on Philippines opens bid for final 3G license