Twitter While You SleepShare
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.
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.| Permalink