SMS and Command Line Fun

Almost all cellphones and carriers support SMS’s now, and sms bundles of hundreds or unlimited plans are really cheap. One spiffy feature that most major carriers provide is email to SMS relaying. Below are some of the major carriers relaying addresses.


AT&T Wireless / Cingular

Boost Mobile



Sprint PCS




So if you want to send a SMS, send a email to the above email format. The from and the subject fields will be added to the message body. Check with your carrier about how long a message can be, usually it’s 160 characters (including the from, subject and body together). Now let’s make things fun.

Sendmail Mashup

Sendmail is nice. Most *nix installations will have it already configured, if not it’s not that hard to setup anyway. Sendmail allows you to send emails through the command line directly, for example you can pipe the message body into sendmail to be sent as the message body.

echo moo | sendmail

Since SMS’s can now be represented by an email address, you can pipe the output of various commands directly into a SMS message. For example, one of the things I use this daily is to be alerted when builds finish that take a long time.

make something && echo "Make Finished" | sendmail

I made it even simpler by writing a bash script named “sms”.

echo "Finished building at `date +%T` -- `pwd`" | sendmail "" &

Ok, so on the unix machines at work, I realized sendmail is not available. So if you want this in a Sun Unix enviornment, use the following with mailto command.

echo "Finished building at `date +%T` -- `pwd`" | mailto "" -s "nix"

This way I can simply append the “&& sms” after any command and when ever the previous command finishes, it will alert me with a quick SMS. The above script will include the username and host name in the from field by default, the time it finished and what the current directory it was in.

Other uses might be if you are doing any type of simulations, you can append this to the end so you know the simulations are done. Other uses might be alert you when a hard drive fails using smartd or other types of triggered alerts. Hope you found this useful.