How to send a text message via command line in OS X

You can send text messages to anyone using Terminal.

OS X Daily recently outlined a new hint which allows you to send text messages to any SMS-supporting phone for free, from the OS X command line (or any OS with a command line supporting the "curl" command).

To do this, you use TextBelt, which is a Web-based SMS API that you can use to text messages using simple POST requests with the "curl" command. For example, to send a text message, you can run the following command:

curl http://textbelt.com/text -d number=4155551111 -d message="The Message Text"

In this example, the message "The Message Text" will be sent as an SMS message to the number (415) 555-1111. If the message is sent successfully, you will receive an output to the command line that reads {"success":true} and if not, then this message will read "false" followed by a brief explanation.

This service can be exceptionally useful, especially if you regularly run scripts on your system to perform backup, maintenance, and other tasks. You can embed this service to run conditionally in your script, so it can notify you if the script completed, or encountered an error, or otherwise ran in a specific way intended or unintended.

While there have been options to spur notifications in Apple's Notification Center from scripts and commands in the OS X Terminal, this is a local notification that will only be visible if you are sitting in front of your computer. Using the TextBelt API, you can have your script send a notice to your phone wherever you are.

Note that if you use this script, there are some limitations noted on the TextBelt Web site. First is they limit you to 75 texts per IP address per day, and only three texts can be sent every three minutes; however, if you require more than these you can make a special request to Ian Webster (creator of the API) to have an exception implemented. In addition, some cell carriers are not supported, but the following should work just fine:

Alltel, Ameritech, AT&T Wireless, Boost, CellularOne, Cingular, Sprint PCS, Telus Mobility, T-Mobile, Metro PCS, Nextel, O2, Orange, Qwest, Rogers Wireless, U.S. Cellular, Verizon, Virgin Mobile.

Finally, note that for some carriers, you may see the incoming message arrive from the address "txt@textbelt.com."



Questions? Comments? Have a fix? Post them below or !
Be sure to check us out on Twitter and the CNET Mac forums.
The MacFixIt blog can be found directly at http://www.macfixit.com

About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Show Comments Hide Comments
    Latest Galleries from CNET
    Tech industry's high-flying 2014
    Uber's tumultuous ups and downs in 2014 (pictures)
    The best and worst quotes of 2014 (pictures)
    A roomy range from LG (pictures)
    This plain GE range has all of the essentials (pictures)
    Sony's 'Interview' heard 'round the world (pictures)