Command Line SMS Fun
Almost all cellphones and carriers support SMS’s now, and 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.
Alltel
1234567890@message.alltel.comAT&T Wireless / Cingular
1234567890@mmode.comBoost Mobile
1234567890@myboostmobile.comCingular
1234567890@mobile.mycingular.com
1234567890@cingularme.comNextel
1234567890@messaging.nextel.comSprint PCS
1234567890@messaging.sprintpcs.comT-Mobile
1234567890@tmomail.netVerizon
1234567890@vtext.comVirgin
1234567890@vmobl.com
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 email@email.com
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 1234567890@tmomail.net
I made it even simpler by writing a bash script named “sms”.
#!/bin/bash
echo "Finished building at `date +%T` -- `pwd`" | sendmail "1234567890@tmomail.net" &
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.
Update for Unix Users
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.
#!/bin/bash
echo "Finished building at `date +%T` -- `pwd`" | mailto "1234567890@tmomail.net" -s "nix"