Twitter While You Sleep
Thursday, May 8th, 2008
Wait until you see what a clever pun this title is. Using the sleep command in Terminal you can update your Twitter status while you’re away. Or sleeping.
Apple has jumped around a little with regards to command line scheduling tools, but the sleep command is still dead-simple to use. (Read more about scheduling with lingon and launchd here)
Suppose you have a command you want to run once, at a future time. Use sleep followed by the number of seconds to wait. Then use a semi-colon to separate the command to run at the appointed time.
sleep 30 ; command
The above example will execute command 30 seconds after you hit the return key. 3600 seconds is an hour. 86,400 seconds in each and every day.
So now you just need a command to update Twitter. The curl command comes with your Mac. Twitter Development Talk boasts the easiest way to update Twitter from the command line. Scroll down to The Easiest Way to Play Around with the Twitter API. Christopher Penn has a post on it too, but the command is cut-off on his blog.
The command should look like this:
curl -u username:password -d status=”your message here” http://twitter.com/statuses/update.xml
Enter that all on one line. It would be better to make it into a shell script. Just copy that line into a text file, maybe name it tw.sh, and replace the your message here part with $1. Then use chmod to make it executable.
Note: Don’t know how to make it executable? Read more about making a shell script. Learn even more about shell scripts: make an interactive shell script.
From there you can enter the following in the Terminal:
./tw.sh “Looking into starting my own airline…”
And you’ve updated your Twitter status. You can make that cleaner by setting an alias for your shell script.
Finally, to have your tweet post onto Twitter hours later you could enter something like this in the Terminal:
sleep 7200; ./tw.sh “I’m sleeping” (you’ll need to leave your Mac on)
If you’re a stickler about your Twittering and want to be accurate, this is the way to go. Schedule that I’m in the shower tweet in advance. People need to know.
This post is intended for people with mobile phones that don’t have Internet access, but can receive emails in the form of text messages. You will also be interested in this post if you’ve had problems with Mail.app rules in Leopard. 

I picked up a stack of Sony DVD+R DL disks this morning in preparation for my first attempt at DL burning. The objective: Backing up my Fusion install of Windows XP onto two disks.
This post is a follow up to Murphy’s post on
If you’re using an iPhone or a touch or some other mobile device this could be a very convenient way to retrieve a file from home and view it on your device.

