Send text messages via the command line
A member of the group posted a request on the mailing list today for more detailed instructions on how to implement the use of a command line script as described in a recent post on Mac OS X Hints. The script describes how to send text messages to Cingular subscribers via the command line.
First, it is important to understand how this process works and what the script is doing. The script is not generating the text message. The script is simply interacting with a script on Cingular’s server; one that normally receives it’s information from a “send a text message” web form hosted on Cingular’s website. This by-passing-the-web-form-without-human-interaction is done with a command line application called Curl. Curl posts the necessary values to the script, virtually “submitting” the form.
Begin by launching Terminal. It is located in the Utilities directory. When Terminal is launched, a new shell session is automatically begun and you are automatically positioned at the root of your home directory within the file system. A shell is a tool to enable users to interact with the system. Usually shells are text based and command line oriented. Examples of popular shells include bash, tcsh and ksh. Shells are usually run in a Terminal window.
Note: The following instructions contain strings of text called “commands.” These are designated in monospaced type and are to be typed into the terminal verbatim, followed by a strike of the return key which executes them.
To begin, we will create a directory called “scripts” inside of the user’s Documents folder to put this script in:
mkdir ~/Documents/scripts
Next, we will create the script. Using the command line text editor vim, open a new, blank document named “curlsms” in the new directory:
vi ~/Documents/scripts/curlsms
Enter edit mode by striking the “i” key. Then, copy the following from this post, switch back to Terminal, and paste it (command + v).
curl -d "from=$1&min=$2&msg=$3" http://www.cingularme.com/do/public/send >> /dev/null
Exit edit mode by striking the escape key. Then save the file, close it, and exist the editor by entering a colon charater (shift + semicolon), an “x” character, and then striking the return key.
The script is now created, but we need to alter the files permissions in order to run it. This is done with the following command:
chmod a+x ~/Documents/scripts/curlsms
Now we are ready to use it. The template for this is:
~/Documents/scripts/curlsms sender number "message"
…replacing “sender” with your name, “number” with the phone number that you are sending the message to, and “message” with the body of the message, in quotes.
About this entry
You’re currently reading “Send text messages via the command line,” an entry on BYU Mac Users Group
- Author:
- Wade Preston Shearer
- Published:
- 09.18.06 / 16:36
- Category:
- Articles
3 Comments
Jump to comment form | comments rss [?] | trackback uri [?]